1

I'm using yaml. So, we can use either:

!GetAtt [ WebServer, AvailabilityZone ]
!GetAtt WebServer.AvailabilityZone

Also, we can use:

!Sub 'sometext-${AWS::StackName}'

how can I use GetAtt output instead of ${AWS::StackName}, preferably using the second form of GetAtt? I do know how to use Join but I'd like to stay with Sub.

Putnik
  • 2,217
  • 4
  • 27
  • 43

1 Answers1

5

Simply remove !GetAtt and reference the desired variable. In the following code EIP.AllocationId normally returned via !GetAtt.

!Sub |
#!/bin/bash
export INSTANCEID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 associate-address --instance-id $INSTANCEID --allow-reassociation --allocation-id ${EIP.AllocationId} --region ${AWS::Region}
spinnerdog
  • 66
  • 1