Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AWSTemplateFormatVersion: "2010-09-09"
- Metadata:
- License: Apache-2.0
- Description: "Create an AWS EC2 instance running the AWS Linux AMI."
- Parameters:
- KeyName:
- Description: Name of an existing EC2 KeyPair
- Type: AWS::EC2::KeyPair::KeyName
- ConstraintDescription: must be the name of an existing EC2 KeyPair.
- Resources:
- Docker01:
- Type: AWS::EC2::Instance
- Properties:
- InstanceType: t2.micro
- SecurityGroups: [!Ref "InstanceSecurityGroup"]
- KeyName: !Ref "KeyName"
- ImageId: ami-0aeeebd8d2ab47354 # us-east-1
- UserData:
- !Base64 |
- #!/bin/bash -xe
- amazon-linux-extras install -y docker=latest
- systemctl enable --now docker.service
- curl -s https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh
- usermod -a -G docker ec2-user
- Tags:
- - Key: Name
- Value: docker-01
- Docker02:
- Type: AWS::EC2::Instance
- Properties:
- InstanceType: t2.micro
- SecurityGroups: [!Ref "InstanceSecurityGroup"]
- KeyName: !Ref "KeyName"
- ImageId: ami-0aeeebd8d2ab47354 # us-east-1
- UserData:
- !Base64 |
- #!/bin/bash -xe
- amazon-linux-extras install -y docker=latest
- systemctl enable --now docker.service
- curl -s https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh
- usermod -a -G docker ec2-user
- Tags:
- - Key: Name
- Value: docker-02
- InstanceSecurityGroup:
- Type: AWS::EC2::SecurityGroup
- Properties:
- GroupDescription: Enable SSH access on port 22
- SecurityGroupIngress:
- - IpProtocol: tcp
- FromPort: 22
- ToPort: 22
- CidrIp: "0.0.0.0/0"
- Outputs:
- PublicDNS01:
- Description: Public DNS Name of the newly created AWS EC2 instance
- Value: !GetAtt [Docker01, PublicDnsName]
- PublicIP01:
- Description: Public IP address of the newly created AWS EC2 instance
- Value: !GetAtt [Docker01, PublicIp]
- PublicDNS02:
- Description: Public DNS Name of the newly created AWS EC2 instance
- Value: !GetAtt [Docker02, PublicDnsName]
- PublicIP02:
- Description: Public IP address of the newly created AWS EC2 instance
- Value: !GetAtt [Docker02, PublicIp]
Add Comment
Please, Sign In to add comment