AWS service catalog recreate new ec2 when updating ebs volumetype from gp2 to gp3

168 Views Asked by At

As on topic, I have created a new service catalog Portfolios > Products with two version.

  1. First version with the below cloudformation template.

  2. Launch the product using the below template is ok. EC2 launched successfully.

  3. Create a second version and modify the cloudformation template for BlockDeviceMapping > DeviceName /dev/xda > Ebs VolumeType to gp3.

  4. It create a new EC2 with Ebs VolumeType gp3 instead of modifying the existing EC2 EBS VolumeType launched from first version.

  5. When checking from Provisioned products > provisioned product plan, the replacement is set to True. I believe this is the issue. How can I make it to use the existing EC2 launched from first version and modify the EBS VolumeType from gp2 to gp3?

  6. Is there a way to update ebs VolumeType to gp3 service catalog?

AWSTemplateFormatVersion: "2010-09-09"
Description: "Create EC2 instance"
Resources: 
EC2Instance: 
DeletionPolicy: Retain
Properties: 
 BlockDeviceMappings: 
 - DeviceName: /dev/xvda
  Ebs:
   VolumeType: gp2
   VolumeSize: 10
IamInstanceProfile: roletest
ImageId: ami-123456
InstanceType: t2.micro
SecurityGroupIds:
 - sg-123456
SubnetId: 123456
 Tags: 
 - 
  Key: Name
  Value: ec2test
Type: "AWS::EC2::Instance"
1

There are 1 best solutions below

3
On

In your current scenario, NO! What you have specified is to persist the root volume of the EC2 instance with the BlockDeviceMapping and DeviceName: /dev/xvda configs.

So when you are changing the type of EBS VolumeType - you change the instance root volume. Which all together make sense why your instance get replaced.

I hope the explanataion make sense!