This message was deleted.
# general
s
This message was deleted.
b
Copy code
/opt/aws/bin/cfn-signal --resource ${ASG_NAME} --stack ${STACK_NAME} --region ${REGION}
🙏 1
r
Which one of these variables are available to me from the EC2 environment? Because I don't have the correct Stack name to put in the user-data script
The stack always get the random suffix at the end so I can't predict what the name will be. Also I'm not managing the stack directly so I can't take it's name attribute as a pulumi output.
b
you might have to look them up during the user_data inside the instance. i haven't tested these, but something like this
Copy code
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)
REGION=$(curl -s <http://169.254.169.254/latest/dynamic/instance-identity/document> | jq .region -r)
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)
r
Wow, incredible, gonna try it now. Thanks a lot again!!
b
btw, the cfn signal might not fix it, if waiting for CFN to update is causing you timeouts, you might want to switch to a pure ASG instead of using
awsx
r
Actually I don't really know what's going on. I'm not sure why the stack is failing and getting rolled back. Maybe it's because of the health check configuration, but I honestly have no clue.
b
are you registering your instances with a load balancer?
r
Yes, I'm pointing the target group associated with the load balancer in the "targetGroups" parameter of the auto scaling group
This isn't enough?
b
if the LB can't reach the instances, the healthcheck will fail and the CFN stack will roll back (I think)
can you DM me more of your code in a github gist?
r
Sure, just one second that I'll generate one
Oh, I'll send it as DM