I am seeing a strange behavior where on a preview ...
# python
s
I am seeing a strange behavior where on a preview it wants to replace the entire ec2 instance because it thinks ebsBlockDevices parameters/objects have changed.. however, it wants to change it to the same name.. AKA, nothing has actually changed, which is correct
b
can you share your code?
r
Jamie was helping me out with this issue. I created this simplified example to help troubleshoot the issue: If I create an AMI from an instance with multiple volumes, and launch an instance from that AMI - if I later try to resize the additional volume on the new instance, Pulumi doesn't resize the volume. Instead it wants to replace the entire instance.
Copy code
"""Testing Multi-Volume AMIs and Post-Deploy Volume Resizing"""

import pulumi
import pulumi_aws as aws

ubuntu_ami = aws.ec2.get_ami(most_recent=True,
    filters=[
        aws.ec2.GetAmiFilterArgs(
            name="name",
            values=["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"],
        ),
        aws.ec2.GetAmiFilterArgs(
            name="virtualization-type",
            values=["hvm"],
        ),
    ],
    owners=["099720109477"])

# Create an instance with an addditional volume
test_ami_origin = aws.ec2.Instance(
    "test_ami_origin",
    ami=ubuntu_ami.id,
    instance_type="t3.micro",
    tags={"Name": "test_ami_origin",},
    ebs_block_devices=[
        aws.ec2.InstanceEbsBlockDeviceArgs(
            device_name="/dev/sdc",
            volume_size=200,
            volume_type="gp2",
        )
    ],
    subnet_id="subnet-014a297abc46f0170"
    )

# Create an AMI from that instance
prod_ppgdb_ami = aws.ec2.AmiFromInstance(
    "prod_ppgdb_ami",
    source_instance_id=test_ami_origin.id,
)

# First, create a new instance from that AMI,
# Then, uncomment the ebs_block_devices attribute and `pulumi up` again.
# This will trigger replacement of the entire instance, instead of resizing the drive.
test_instance_from_ami = aws.ec2.Instance(
    "test_instance_from_ami",
    ami=prod_ppgdb_ami.id,
    instance_type="t3.micro",
    subnet_id="subnet-014a297abc46f0170",
    # ebs_block_devices=[
    #     aws.ec2.InstanceEbsBlockDeviceArgs(
    #         device_name="/dev/sdc",
    #         volume_size=250,
    #         volume_type="gp2",
    #     )]
    )
s
@billowy-army-68599 sorry, just seeing this, JC posted the code in the channel
r
I cross posted this to #general since it doesn't seem python-specific
c