Create EC2 and Terminate ECS instance using Ansible

root@ip-172-31-1-140 playbook]# cat task.yml
---
- name: ec2 launcher
  hosts: localhost
  tasks:
  - name: launching ec2
    ec2:
         instance_type: t2.micro
         key_name: DevOps-key
         image: ami-03d62b340566461c7
         region: us-east-2
         group: DevOps-Sec
         count: 1
         vpc_subnet_id: subnet-68ebf400
         wait: yes
         assign_public_ip: yes
         instance_tags:
          Name: test1
         #register: ec2
[root@ip-172-31-1-140 playbook]#

### Terminate Instance ###

[root@ip-172-31-30-99 ~]# cat terminate.yml
---
- name: Terminate instances
  hosts: localhost
  tasks:
    - name: Terminate instances that were previously launched
      ec2:
        state: 'absent'
        region: 'us-east-2'
        instance_ids: 'i-0ae3a0f862b89f2a6'
[root@ip-172-31-30-99 ~]#

Comments

Popular posts from this blog

Push command for NetWorker Client Upgrade

Factors Affecting Users’ Sense of Security and Trust in Integrating Electronic health record to the cloud

Basic Elastic Cloud Storage Troubleshooting Commands