EC2 pair keys generation failing to show up in AWS AMI info

6 views
Skip to first unread message

flynn

unread,
Mar 18, 2018, 3:09:22 AM3/18/18
to Ansible Project
My code works and returns the ssh fingerprint of my code and returns the keypair name... however, I do not find my created keypair name in the AWS console with newly made aws instance. This means that there's permission error on AWS, Ansible code logic error, or lack of understanding the EC2 configuration.

---
#basic provisioning example
    - name: Create AWS resources
      hosts: localhost
      connection: local
      gather_facts: False
      tasks:
      - name: Create an EC2 instance
        ec2:
          aws_access_key: "{{ lookup('env','AWS_ACCESS_KEY_ID') }}"
          aws_secret_key: "{{ lookup('env','AWS_SECRET_ACCESS_KEY') }}"
          region: "{{  AWS_REGION  }}"
          instance_type: "t2.small"
          image: "ami-99ci9r99"
          wait: yes
          volumes:
            - device_name: /dev/sda1
              volume_type: gp2
              volume_size: 10
              delete_on_termination: true
          exact_count: 1
          count_tag:
             Name: aws-demo
          instance_tags:
             Name: aws-demo
        register: ec2
      - name: Create a new EC2 key
        ec2_key:
             region: "{{  AWS_REGION  }}"
             name: project
        register: keypair


Reply all
Reply to author
Forward
0 new messages