Hey everyone, I'm new on the slack. I'm having iss...
# general
Hey everyone, I'm new on the slack. I'm having issues importing an instance because I can't get the userData to match what pulumi expects. seems to not be comparing the same things
Copy code
= aws:ec2/instance:Instance: (import)
      ~ userData: "30621d02b5ac13e6f64317c24a64c73d15c3ca1a" => "30621d02b5ac13e6f64317c24a64c73d15c3ca1a"
On the left seems to be a sha on the right I passed the string value of that sha
This is what code is being run with the password secret changed to simply
for obvious reasons
Copy code
const existingUserData = `Content-Type: multipart/mixed; boundary="MIMEBOUNDARY"
MIME-Version: 1.0

Content-Disposition: attachment; filename="setup.cnf"
Content-Transfer-Encoding: 7bit
Content-Type: text/x-shellscript
Mime-Version: 1.0

#!/bin/bash -x
service redis-server stop

sed -i 's/^bind' /etc/redis/redis.conf

# Protect
if [[ 0 == "1" ]]; then
	sed -i 's/^# requirepass foobared/requirepass "$PASSWORD"/' /etc/redis/redis.conf
# Do not protect
if [[ 0 == "0" ]]; then
	sed -i 's/^protected-mode yes/protected-mode no/' /etc/redis/redis.conf

service redis-server start
  const redisInstance = new aws.ec2.Instance(
      ami: tfRedisConfig.amiId,
      instanceType: tfRedisConfig.instanceType,
      subnetId: tfRedisConfig.subnetId,
      associatePublicIpAddress: false,
      userData: existingUserData,
      tags: {
        Name: `${tfRedisConfig.name}-redis-${tfRedisConfig.env}-${tfRedisConfig.awsRegion}`,
        Region: tfRedisConfig.awsRegion,
        Env: tfRedisConfig.env
      import: "i-0fd1d213dcf923405",
      deleteBeforeReplace: false
I pulled that userdata directly from the running EC2 instance. It seems to me like it's comparing the literal value of the userdata to the sha of the userdata in ec2
Might've figured this one out by using
aws ec2 describe-instance-attribute --instance-id INSTANCE_ID --attribute userData | jq '.UserData.Value' - -r | base64 -D | pbcopy
to grab exact value for user data.
Note that you can also add
{ ignoreChanges: [“userData”] }
in the resource options to skip any perceived changes to the userData. You then can’t update this property via Pulumi (unless you remove the ignoreChanges) but that might be what you want here.
👍 1
Yea, the ignoreChanges is what I had to do. I couldn't figure out what changed which caused the problem