https://github.com/andrejmaya/aws-ec2-docker_ansible
Create a EC2 with Ansible
https://github.com/andrejmaya/aws-ec2-docker_ansible
Last synced: 8 months ago
JSON representation
Create a EC2 with Ansible
- Host: GitHub
- URL: https://github.com/andrejmaya/aws-ec2-docker_ansible
- Owner: andrejmaya
- Created: 2018-01-05T20:05:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-29T13:29:15.000Z (over 8 years ago)
- Last Synced: 2025-03-02T05:27:46.335Z (over 1 year ago)
- Homepage:
- Size: 10.7 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AWS EC2 Ansible Docker example
Create and connect to a AWS EC2 instance made simple
## Prerequisites
* Docker installed
* AWS user with these permissions:
* `AmazonEC2FullAccess`
* `SecurityAudit`
* Configurations can be made in the `inventory` file.
## Create EC2 instance
Please add your AWS user credentials to the `inventory` file:
```
ec2_access_key="YOUR_AWS_ACCESS_KEY_ID"
ec2_secret_key="YOUR_AWS_SECRET_ACCESS_KEY"
```
And execute following statement:
```
docker run -it --rm -v $(pwd):/ansible \
ryanwalls/ansible-aws:v2.3.1.0-1 sh -c "ansible-playbook -i ./inventory ec2-basic.yml"
```
## Multiple instances per user
* copy the `id_rsa_your_name.pub` key into the `deploy_keys` directory.
* add role execution to `ec2-basic.yml` like this:
```
- { role: ec2_basic, key_name: 'id_rsa_joe', tags: basic}
- { role: ec2_basic, key_name: 'id_rsa_peter', tags: basic}
- { role: ec2_basic, key_name: 'id_rsa_julia', tags: basic}
```
## SSH connection
look up the public ip in the `inventory` file underneath `[playground]` block and pass it to:
`ssh -i ./deploy_keys/ @`
## Delete EC2 instance
Uncomment the `FOR DELETION ONLY` block in the `inventory` file and enter the correct ec2 instance id
## Known issues
* `IdempotentInstanceTerminated: The client token you have provided is associated with a terminated instance. Please use a different client token`: Please change the `key_name` variable in `inventory` to create a new instance(s)