https://pulumi.com logo
#general
Title
# general
c

cuddly-alligator-37434

06/14/2022, 9:19 AM
Hi all, I have an issue with the AutoScalingGroup AWS. I need to specify my own userData in the launch configuration. Yet I am unable to remove the suffix from and therefore predict the stack name. As a result I can do whatever i want in my user data but can never send the signal to cloudformation and my stack creation always fail Any pointer on how to get out of this?
e

echoing-dinner-19531

06/14/2022, 9:53 AM
If so you can always just set the resource name explicitly
b

billowy-army-68599

06/14/2022, 12:39 PM
@cuddly-alligator-37434 you can retrieve the ASG from within the user data:
Copy code
# cloudformation stack name
STACK_NAME=$(aws ec2 describe-instances --instance-id $(curl -s <http://169.254.169.254/latest/dynamic/instance-identity/document> | jq .instanceId -r) --region eu-west-1 --query "Reservations[*].Instances[*].Tags[?Key=='aws:cloudformation:stack-name'].Value" --output text)
# aws region
REGION=$(curl -s <http://169.254.169.254/latest/dynamic/instance-identity/document> | jq .region -r)
# the name of the ASG this instance is in
ASG_NAME=$(aws ec2 describe-instances --instance-id $(curl -s <http://169.254.169.254/latest/dynamic/instance-identity/document> | jq .instanceId -r) --region eu-west-1 --query "Reservations[*].Instances[*].Tags[?Key=='aws:autoscaling:groupName'].Value" --output text)
c

cuddly-alligator-37434

06/14/2022, 12:42 PM
@echoing-dinner-19531 thank you! as far as I could see, there is no option to do that on the autoscaling group (not on cluster.addAutoscalingGroup and cluster.createAutoScalingGroup)
@billowy-army-68599 I think that will work!! thank you
b

billowy-army-68599

06/14/2022, 12:45 PM
you'll need to make sure it has an IAM role that allows it to read those values of course
c

cuddly-alligator-37434

06/14/2022, 12:48 PM
Sure 🙂
13 Views