I am trying to automate the creation of an EC2 instance with CloudFormation but am running into issues with DNS.
Once the instance is created it can't seem to resolve any hostnames. I try to ping a hostname, such as google.com, and it can't be resolved. However, it can ping IP addresses.
My template is below and I understand that there are some unused parameters which I intend to use later on:
{ "Description": "Create an EC2 instance by AWS CloudFormation", "Parameters": {
"KeyName": {
"MinLength": 1,
"Type": "AWS::EC2::KeyPair::KeyName"
},
"BaseAmiId": {
"Default": "ami-bd3ba0aa",
"Type": "String"
},
"DomainAdminUser": {
"Description": "User name for the account that will be added as Domain Administrator. This is separate from the default \"Administrator\" account",
"Type": "String",
"Default": "installer"
},
"DomainUserPassword": {
"NoEcho": "true",
"Description": "The Windows administrator account password",
"Type": "String",
"MinLength": "8",
"MaxLength": "41"
},
"DomainDNSName": {
"Description": "Fully qualified domain name (FQDN) of the forest root domain",
"Type": "String",
"Default": "test.com"
},
"DomainNetBiosName": {
"Description": "Netbios name for the domain",
"Type": "String",
"Default": "test"
} }, "Resources": {
"SecurityGroupDemoSvrTraffic": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupName": "sgDemoSvr",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": 3389,
"ToPort": 3389,
"CidrIp": "0.0.0.0/0",
"Description": "For traffic from Internet"
}
],
"GroupDescription": "Security Group for demo server",
"VpcId": "vpc-05eabde4dbadsf09"
}
},
"EC2Instance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"AvailabilityZone": "eu-west-2b",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"DeleteOnTermination": "true",
"VolumeSize": "32",
"VolumeType": "gp2"
}
}
],
"ImageId": "ami-029c4f36a959979a7",
"InstanceType": "t2.micro",
"KeyName": {
"Ref": "KeyName"
},
"NetworkInterfaces": [
{
"Description": "Primary network interface",
"DeviceIndex": "0",
"SubnetId": "subnet-0b3f36d19eb3sdfda",
"AssociatePublicIpAddress": true,
"GroupSet": [
{
"Ref": "SecurityGroupDemoSvrTraffic"
}
]
}
]
}
} }}