Problem with resource_tags

Hi Everyone,
I am trying to create a VPC using Ansible however I am having trouble in tagging resoruces

`

  • name: Create a VPC
    register: vpc
    ec2_vpc:
    state: present
    cidr_block: 10.0.0.0/16

resource_tags: { Environmenti: Development }

subnets:

  • cidr: 10.0.0.0/24
    az: us-east-1a
    resource_tags:
    Name: Development Public Subnet
  • cidr: 10.0.1.0/24
    az: us-east-1b
    resource_tags:
    Name: Development Private Subnet A
  • cidr: 10.0.2.0/24
    az: us-east-1d
    resource_tags:
    Name: Development Private Subnet B
    wait: yes
    region: us-east-1
    internet_gateway: yes

`

With the above code getting executed successfully, still the subnets dont have the Tag of " Name ", the Tag gets created but its value remains empty

Also If I try to tag the VPC, I get the following error with the below code

`

  • name: Create a VPC
    register: vpc
    ec2_vpc:
    state: present
    cidr_block: 10.0.0.0/16
    resource_tags: { Environmenti: Development }
    subnets:
  • cidr: 10.0.0.0/24
    az: us-east-1a
    resource_tags:
    Name: Development Public Subnet
  • cidr: 10.0.1.0/24
    az: us-east-1b
    resource_tags:
    Name: Development Private Subnet A
  • cidr: 10.0.2.0/24
    az: us-east-1d
    resource_tags:
    Name: Development Private Subnet B
    wait: yes
    region: us-east-1
    internet_gateway: yes

`

PLAY [local] ******************************************************************

TASK: [Create a VPC] **********************************************************
failed: [localhost] => {“failed”: true}
msg: unsupported parameter for module: resource_tags

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/root/main.retry

Can anyone point out what I am doing wrong.Thank you :slight_smile:

Try this:

`

  • name: Create a VPC
    local_action:
    module: ec2_vpc
    state: present
    cidr_block: 10.0.0.0/16
    resource_tags: { “Environment”: “Development” }
    subnets:
  • cidr: 10.0.0.0/24
    az: us-east-1a
    resource_tags: { “Environment”:“Development”, “Name” : “Public Subnet” }
  • cidr: 10.0.1.0/24
    az: us-east-1b
    resource_tags: { “Environment”:“Development”, “Name” : “Private Subnet A” }
  • cidr: 10.0.2.0/24
    az: us-east-1d
    resource_tags: { “Environment”:“Development”, “Name” : “Private Subnet B” }
    wait: yes
    region: us-east-1
    internet_gateway: yes
    register: vpc

`

Hi,
Even After trying your suggestion. I am getting the following error

failed: [localhost → 127.0.0.1] => {“failed”: true}
msg: unsupported parameter for module: resource_tags

FATAL: all hosts have already failed – aborting

This is happening for

`

tasks:

  • name: Create a VPC
    register: vpc
    local_action:
    module: ec2_vpc
    state: present
    cidr_block: 10.0.0.0/16
    resource_tags: { “Environment”: “Development” }
    subnets:
  • cidr: 10.0.0.0/24
    az: us-east-1a
    resource_tags: { “Environment”: “Development”, “Name” : “Public Subnet” }

`