steampunk.aws.ec2_vpc (0.9.0) — module

Manage EC2 VPCs

Authors: Manca Bizjak (@mancabizjak), Aljaz Kosir (@aljazkosir), Saso Stanovnik (@sstanovnik), Miha Dolinar (@mdolinar), Tadej Borovsak (@tadeboro)

preview | supported by XLAB Steampunk

Install collection

Install with ansible-galaxy collection install steampunk.aws:==0.9.0


Add to requirements.yml

  collections:
    - name: steampunk.aws
      version: 0.9.0

Description

Create, update or delete an AWS EC2 Virtual Private Cloud.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a VPC
  ec2_vpc:
    name: my-vpc
    cidr: 10.0.0.0/16
    instance_tenancy: dedicated
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update VPC's instance tenancy
  ec2_vpc:
    id: "{{ result.object.id }}"
    instance_tenancy: default
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Clear all VPC's tags
  ec2_vpc:
    id: "{{ result.object.id }}"
    clear_tags: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete a VPC
  ec2_vpc:
    id: "{{ result.object.id }}"
    state: absent

Inputs

    
id:
    description:
    - ID of the resource to perform the task on.
    - If specified, this parameter is used to identify the resource.
    - Omit this parameter when you are first creating the resource.
    type: str

auth:
    description:
    - Parameters for authenticating with the AWS service. Each of them may be defined
      via environment variables.
    suboptions:
      access_key:
        description:
        - The AWS access key ID. If not set, the value of the AWS_ACCESS_KEY environment
          variable will be checked.
        - Mutually exclusive with I(profile).
        required: false
        type: str
      profile:
        description:
        - The name of the AWS profile configured with C(aws configure).
        - Can be used instead of explicitly specifying your access credentials and region.
        - Use C(default) to use the default profile.
        - Mutually exclusive with I(access_key) and I(secret_key).
        required: false
        type: str
      region:
        description:
        - The name of the AWS region.
        - If not set, the value of the AWS_REGION environment variable will be checked.
        - If you set a I(profile) that specifies a default region, that region is used
          and you can omit this parameter. Use this parameter to override the profile's
          default region.
        type: str
      secret_key:
        description:
        - The AWS secret access key. If not set, the value of the AWS_SECRET_KEY environment
          variable will be checked.
        - Mutually exclusive with I(profile).
        required: false
        type: str
      url:
        description:
        - The URL to the AWS service related to the resource. By default, this is automatically
          determined through the region parameter.
        - If not set explicitly, the value of the AWS_<SERVICE>_URL environment variable
          will be used.
        - The services currently supported are EC2 and S3.
        required: false
        type: str
    type: dict

cidr:
    description:
    - IPv4 network range to assign to the VPC, in CIDR notation.
    - This parameter is required unless I(id) is provided.
    - In the absence of I(id), the value of this parameter will be used together with
      the value of I(name) to uniquely identify the VPC.
    type: str

name:
    description:
    - Name of the VPC.
    - This parameter is required unless I(id) is provided.
    - The value of this parameter will be used together with the value of I(cidr) to uniquely
      identify the VPC.
    type: str

tags:
    description:
    - Metadata for the AWS resource as key/value pairs.
    - Keys and values are case-sensitive.
    type: dict

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Target state of the AWS resource.
    type: str

clear_tags:
    default: false
    description:
    - Whether to clear any existing tags on the resource that are not explicitly stated
      in I(tags).
    - By default, existing tags are kept on the resource.
    - When this parameter is set to C(true), any pre-existing tags on the resource (including
      the name tag) are removed. To clear all tags except the name tag, make sure to provide
      the I(name) parameter.
    type: bool

instance_tenancy:
    choices:
    - default
    - dedicated
    description:
    - Allowed tenancy for EC2 instances launched into the VPC.
    - Once a VPC is created with C(dedicated) tenancy, you may update the parameter to
      C(default), but not vice versa. Note that the the change will take effect for newly
      launched instances only.
    type: str

Outputs

object:
  contains:
    cidr:
      description: The CIDR block for the VPC.
      returned: always
      type: str
    id:
      description: The ID of the VPC.
      returned: always
      type: str
    instance_tenancy:
      description: The instance tenancy setting for instances launched in the VPC.
      returned: always
      type: str
    tags:
      description: The tags assigned to the VPC.
      returned: always
      type: dict
  description:
  - An object representing an EC2 VPC.
  returned: success and I(state=present)
  sample:
    object:
      cidr: 10.0.0.0/16
      id: vpc-123456
      instance_tenancy: dedicated
      tags:
        bu: finance
  type: dict

See also