
Explanation:
!Sub substitutes ${AWS::StackName} with the actual stack name at runtime. If the stack is named prod-stack, the tag value resolves to prod-stack-AppServer.
Ultimate access to all questions.
CloudFormation Question 8: What will the Name tag value resolve to at runtime for the stack named 'prod-stack'?
AWSTemplateFormatVersion: '2010-09-09'
Resources:
AppServer:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0abcdef1234567890
InstanceType: t3.medium
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-AppServer'
AWSTemplateFormatVersion: '2010-09-09'
Resources:
AppServer:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-0abcdef1234567890
InstanceType: t3.medium
Tags:
- Key: Name
Value: !Sub '${AWS::StackName}-AppServer'
A
${AWS::StackName}-AppServer (literal string)
B
prod-stack-AppServer
C
AppServer
D
An error — AWS::StackName cannot be used with !Sub
E
None of the above
F
Not applicable
No comments yet.