Open Kazy opened 9 months ago
Hi @Kazy. Thanks for filing a bug. I don't see this behavior when creating an aws.ec2.Instance
and running pulumi up
. Can you post steps so I can reproduce this on my computer.
Hi @Kazy. Thanks for filing a bug. I don't see this behavior when creating an
aws.ec2.Instance
and runningpulumi up
. Can you post steps so I can reproduce this on my computer.
Unfortunately I don't think I can. This only happened on one of our env that I imported but not the other. The instance was originally created using Terraform and then imported, if that's help. Considering I can't provide a repro, I'll gladly help test anything that might help. We can also hop on a call if needed, let me know.
I have a similar problem when creating ec2 instance using launch template that has user_data. The diff doesn't show any changes.
Below code can be used to re-produce the problem. (Workaround is adding ignore_changes=["user_data"]
to avoid the update)
import base64
import pulumi
import pulumi_aws as aws
ubuntu = aws.ec2.get_ami(
most_recent=True,
filters=[
aws.ec2.GetAmiFilterArgs(
name="name",
values=["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"],
),
aws.ec2.GetAmiFilterArgs(
name="virtualization-type",
values=["hvm"],
),
],
owners=["099720109477"],
)
default = aws.ec2.DefaultVpc(
"default",
tags={
"Name": "Default VPC",
},
)
user_data = """#!/bin/bash
echo "Hello World"
"""
encoded_user_data = base64.b64encode(user_data.encode()).decode()
launch_template = aws.ec2.LaunchTemplate(
"default_launch_template",
name_prefix="default",
image_id=ubuntu.id,
instance_type="t3.micro",
user_data=encoded_user_data,
)
web = aws.ec2.Instance(
"web",
launch_template=aws.ec2.InstanceLaunchTemplateArgs(
id=launch_template.id,
version="$Latest",
),
tags={
"Name": "HelloWorld",
},
# opts=pulumi.ResourceOptions(ignore_changes=["user_data"]),
)
Still reproduces for me. I was looking at the upstream definition for ec2.Instance and it's a little interesting.
"user_data": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ConflictsWith: []string{"user_data_base64"},
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
// Sometimes the EC2 API responds with the equivalent, empty SHA1 sum
// echo -n "" | shasum
if (old == "da39a3ee5e6b4b0d3255bfef95601890afd80709" && new == "") ||
(old == "" && new == "da39a3ee5e6b4b0d3255bfef95601890afd80709") {
return true
}
return false
},
StateFunc: func(v interface{}) string {
switch v := v.(type) {
case string:
return userDataHashSum(v)
default:
return ""
}
},
ValidateFunc: validation.StringLenBetween(0, 16384),
},
In the statefile I see
"userData": "09c5cea10b191a7b79a797e9a0673dc0c89a29aa",
Curious if da39a3ee5e6b4b0d3255bfef95601890afd80709 magic is now 09c5cea10b191a7b79a797e9a0673dc0c89a29aa magic that similarly needs ignoring, but could not find any reference for this. If this theory is right the issue should reproduce upstream in plain TF also.
pulumi about:
CLI
Version 3.130.0
Go Version go1.22.6
Go Compiler gc
Plugins
KIND NAME VERSION
resource aws 6.52.0
language python unknown
Host
OS darwin
Version 14.6.1
Arch arm64
This project is written in python: executable='/Users/anton/Library/Mobile Documents/com~apple~CloudDocs/pulumi-bugs/pulumi-aws-3449/venv/bin/python' version='3.10.13'
Current Stack: anton-pulumi-corp/pulumi-aws-3449/dev
TYPE URN
pulumi:pulumi:Stack urn:pulumi:dev::pulumi-aws-3449::pulumi:pulumi:Stack::pulumi-aws-3449-dev
pulumi:providers:aws urn:pulumi:dev::pulumi-aws-3449::pulumi:providers:aws::default_6_52_0
aws:ec2/launchTemplate:LaunchTemplate urn:pulumi:dev::pulumi-aws-3449::aws:ec2/launchTemplate:LaunchTemplate::default_launch_template
aws:ec2/defaultVpc:DefaultVpc urn:pulumi:dev::pulumi-aws-3449::aws:ec2/defaultVpc:DefaultVpc::default
aws:ec2/instance:Instance urn:pulumi:dev::pulumi-aws-3449::aws:ec2/instance:Instance::web
Found no pending operations associated with dev
Backend
Name pulumi.com
URL https://app.pulumi.com/anton-pulumi-corp
User anton-pulumi-corp
Organizations anton-pulumi-corp, moolumi, demo, pulumi
Token type personal
Dependencies:
NAME VERSION
pip 24.2
pulumi_aws 6.52.0
setuptools 75.1.0
wheel 0.44.0
Pulumi locates its logs in /var/folders/gd/3ncjb1lj5ljgk8xl5ssn_gvc0000gn/T/com.apple.shortcuts.mac-helper// by default
I have filed https://github.com/hashicorp/terraform-provider-aws/issues/39476 as it indeed reproduces upstream and best be fixed there. You can help by up-voting this issue.
@t0yv0 09c5cea10b191a7b79a797e9a0673dc0c89a29aa
is the sha1 of:
#!/bin/bash
echo "Hello World"
What happened?
We've imported our current infrastructure into Pulumi. When running
pulumi up
, all our EC2 instances are shown as requiring an update, but when going into the diff, nothing changes. Accepting the update and runningpulumi up
again does the same thing, meaning we have no way of resolving the drift. Doingpulumi refresh
shows no change.This doesn't happen when using version
6.8
of this provider, the bug starts happening from6.9
up to the latest6.22
.Example
First run:
Second run:
Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).