A CloudOps engineer is examining the following AWS CloudFormation template:
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Creates an EC2 Instance'
Resources:
EC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-79fd7eee
InstanceType: m5n.large
SubnetId: subnet-1abc3d3fg
PrivateDnsName: ip-10-24-34-0.ec2.internal
Tags:
- Key: Name
Value: !Sub "${AWS::StackName} Instance"
Why will the stack creation fail?
The PrivateDnsName attribute of an EC2 instance is automatically assigned by AWS at launch time and is a read-only property. CloudFormation does not allow users to specify this value manually.
Including PrivateDnsName in the EC2 instance properties causes validation to fail during stack creation. Outputs and Parameters sections are optional, and the VPC is implicitly defined through the subnet ID.
Therefore, attempting to set PrivateDnsName results in stack creation failure.
Currently there are no comments in this discussion, be the first to comment!