Giter Club home page Giter Club logo

aws-ec2-docker_ansible's Introduction

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/<key_name> <ansible_ssh_user>@<PUBLIC_IP>

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.