File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/boto_vpc.cpython-310.pyc
Back
o ;j� � @ s� d Z ddlZddlm mZ dZe�e�Zdd� Z d1dd�Z d2dd �Z d3d d�Z d4dd �Z d5dd�Zdd� Z d4dd�Z d6dd�Z d7dd�Z d8dd�Z d6dd�Z d2dd�Z d6dd �Zd9d!d"�Z d6d#d$�Z d:d%d&�Z d6d'd(�Z d;d)d*�Z d;d+d,�Z d4d-d.�Z d4d/d0�ZdS )<aB Manage VPCs ================= .. versionadded:: 2015.8.0 :depends: - boto >= 2.8.0 - boto3 >= 1.2.6 Create and destroy VPCs. Be aware that this interacts with Amazon's services, and so may incur charges. This module accepts explicit vpc credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More information available `here <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html>`_. If IAM roles are not used you need to specify them either in a pillar file or in the minion's config file: .. code-block:: yaml vpc.keyid: GKTADJGHEIQSXMKKRBJ08H vpc.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs It's also possible to specify ``key``, ``keyid`` and ``region`` via a profile, either passed in as a dict, or as a string to pull from pillars or minion config: .. code-block:: yaml myprofile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 .. code-block:: yaml aws: region: us-east-1: profile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 .. code-block:: jinja Ensure VPC exists: boto_vpc.present: - name: myvpc - cidr_block: 10.10.11.0/24 - dns_hostnames: True - region: us-east-1 - keyid: GKTADJGHEIQSXMKKRBJ08H - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs Ensure subnet exists: boto_vpc.subnet_present: - name: mysubnet - vpc_id: vpc-123456 - cidr_block: 10.0.0.0/16 - region: us-east-1 - profile: myprofile {% set profile = salt['pillar.get']('aws:region:us-east-1:profile' ) %} Ensure internet gateway exists: boto_vpc.internet_gateway_present: - name: myigw - vpc_name: myvpc - profile: {{ profile }} Ensure route table exists: boto_vpc.route_table_present: - name: my_route_table - vpc_id: vpc-123456 - routes: - destination_cidr_block: 0.0.0.0/0 instance_id: i-123456 - subnet_names: - subnet1 - subnet2 - region: us-east-1 - profile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs .. versionadded:: 2016.11.0 Request, accept and delete VPC peering connections. VPC peering connections can be named allowing the name to be used throughout the state file. Following example shows how to request and accept a VPC peering connection. .. code-block:: yaml accept the vpc peering connection: boto_vpc.accept_vpc_peering_connection: - conn_name: salt_vpc_peering - region: us-west-2 - require: - boto_vpc: request a vpc peering connection request a vpc peering connection: boto_vpc.request_vpc_peering_connection: - requester_vpc_id: vpc-4a3d522e - peer_vpc_id: vpc-ae81e9ca - region: us-west-2 - conn_name: salt_vpc_peering VPC peering connections need not be named. In this case the VPC peering connection ID should be used in the state file. .. code-block:: yaml accept the vpc peering connection: boto_vpc.accept_vpc_peering_connection: - conn_id: pcx-1873c371 - region: us-west-2 VPC peering connections can be deleted, as shown below. .. code-block:: yaml delete a named vpc peering connection: boto_vpc.delete_vpc_peering_connection: - conn_name: salt_vpc_peering Delete also accepts a VPC peering connection id. .. code-block:: yaml delete a vpc peering connection by id: boto_vpc.delete_vpc_peering_connection: - conn_id: pcx-1873c371 � NZboto_vpcc C s$ d} d}dt v r tS dd�| |�fS )z) Only load if boto is available. z2.8.0z1.2.6�boto_vpc.existsFzbThe following libraries are required to run the boto_vpc state module: boto >= {} and boto3 >= {}.)�__salt__�__virtualname__�format)Zboto_versionZ boto3_version� r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/boto_vpc.py�__virtual__� s �r c C s | ddi d�} t d | ||||| d�}d|v r(d| d<