Skip to content

Commit d8d6047

Browse files
authored
use elasticIP (#23)
1 parent b16e744 commit d8d6047

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

cloudformation/common-ec2-instance-template.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22
Description: CloudFormation template for creating EC2 instances with same
3-
permission policy, AZ, and existing security groups
3+
permission policy, AZ, and existing security groups, and bind with Elastic IP
44

55
Parameters:
66
InstanceType:
@@ -57,13 +57,26 @@ Resources:
5757
Roles:
5858
- coseeing-ec2-common
5959

60+
ElasticIP:
61+
Type: AWS::EC2::EIP
62+
Properties:
63+
Domain: vpc
64+
65+
EIPAssociation:
66+
Type: AWS::EC2::EIPAssociation
67+
Properties:
68+
InstanceId: !Ref EC2Instance
69+
AllocationId: !GetAtt ElasticIP.AllocationId
70+
6071
Outputs:
6172
InstanceId:
6273
Description: The Instance ID
6374
Value: !Ref EC2Instance
75+
76+
InstancePublicIp:
77+
Description: The Elastic IP address associated with the instance
78+
Value: !Ref ElasticIP
79+
6480
PublicDNS:
6581
Description: Public DNS of the EC2 instance
6682
Value: !GetAtt EC2Instance.PublicDnsName
67-
InstancePublicIp:
68-
Description: The public IP address of the EC2 instance
69-
Value: !GetAtt [EC2Instance, PublicIp]

0 commit comments

Comments
 (0)