
Explanation:
DependsOn forces CloudFormation to wait until the specified resource (MyDB) is created before starting creation of the dependent resource (AppServer).
Ultimate access to all questions.
CloudFormation Question 9: What is the purpose of the DependsOn attribute in the template below?
Resources:
MyDB:
Type: AWS::RDS::DBInstance
Properties:
DBInstanceClass: db.t3.micro
Engine: mysql
MasterUsername: admin
MasterUserPassword: !Ref DBPassword
AppServer:
Type: AWS::EC2::Instance
DependsOn: MyDB
Properties:
ImageId: ami-0abcdef1234567890
InstanceType: t3.small
Resources:
MyDB:
Type: AWS::RDS::DBInstance
Properties:
DBInstanceClass: db.t3.micro
Engine: mysql
MasterUsername: admin
MasterUserPassword: !Ref DBPassword
AppServer:
Type: AWS::EC2::Instance
DependsOn: MyDB
Properties:
ImageId: ami-0abcdef1234567890
InstanceType: t3.small
A
AppServer will be deleted before MyDB during stack deletion
B
AppServer will not be created until MyDB is successfully created
C
AppServer and MyDB will be created in parallel
D
AppServer will inherit the security group from MyDB
E
None of the above
F
Not applicable
No comments yet.