Created
June 24, 2020 15:26
-
-
Save sohelamin/0e8bf43337ff55ee1a4b5d5069aa3128 to your computer and use it in GitHub Desktop.
AWS CloudFormation EC2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Resources: | |
MyEC2Instance: | |
Type: AWS::EC2::Instance | |
Properties: | |
AvailabilityZone: us-east-1a | |
ImageId: ami-068663a3c619dd892 # Ubuntu Server 20.04 LTS | |
InstanceType: t2.micro | |
KeyName: my-test-key # Existing key pair | |
SecurityGroups: | |
- !Ref MyEC2SecurityGroup | |
Tags: | |
- | |
Key: Name | |
Value: My EC2 Instance | |
UserData: | |
Fn::Base64: !Sub | | |
#!/bin/bash | |
apt-get update | |
apt-get -y install nginx | |
service nginx start | |
MyEIP: | |
Type: AWS::EC2::EIP | |
Properties: | |
InstanceId: !Ref MyEC2Instance | |
MyEC2SecurityGroup: | |
Type: AWS::EC2::SecurityGroup | |
Properties: | |
GroupDescription: My EC2 Security group | |
SecurityGroupIngress: | |
- CidrIp: 0.0.0.0/0 | |
FromPort: 80 | |
IpProtocol: tcp | |
ToPort: 80 | |
- CidrIp: 0.0.0.0/0 | |
FromPort: 443 | |
IpProtocol: tcp | |
ToPort: 443 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage