Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (5.6k points)

This is my ansible-playbook  

---

- hosts: localhost

  connection: local

  tasks:

    - include_vars: aws_credentials.yml

    - name: Creating EC2 Ubuntu instance

      ec2:

        instance_type: t2.micro

        image: ami-86e0ffe7

        region: us-west-1

        key_name: my-key

        zone: us-west-1a

        vpc_subnet_id: subnet-04134e61

        group_id: sg-cf6754ba

        assign_public_ip: yes

..

but I'm getting the error "Could not create Ec2 instance". Any Solution for this 

 

1 Answer

0 votes
by (12.4k points)

Here you should have provided keys directly to EC2 modules

- name: Creating EC2  instance

      ec2:

        aws_access_key: "{{ ec2_access_key }}"

        aws_secret_key: "{{ ec2_secret_key }}"

        instance_type: t2.micro

        image: ami-86e0ffe7

        region: us-west-1

        ...

Want to learn more about AWS, visit: AWS Training

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer

Browse Categories

...