File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/boto_secgroup.cpython-310.pyc
Back
o ;j́ � @ s� d Z ddlZddlZddlm mZ ddlmZ e�e �Z dd� Z ddd�Z dd d �Z dd� Zd d� Zdd� Z ddd�Z ddd�Z ddd�Z ddd�ZdS )aR Manage Security Groups ====================== .. versionadded:: 2014.7.0 Create and destroy Security Groups. Be aware that this interacts with Amazon's services, and so may incur charges. This module uses ``boto``, which can be installed via package, or pip. This module accepts explicit EC2 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 secgroup.keyid: GKTADJGHEIQSXMKKRBJ08H secgroup.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 Ensure mysecgroup exists: boto_secgroup.present: - name: mysecgroup - description: My security group - vpc_name: myvpc - rules: - ip_protocol: tcp from_port: 80 to_port: 80 cidr_ip: - 10.0.0.0/8 - 192.168.0.0/16 - ip_protocol: tcp from_port: 8080 to_port: 8090 cidr_ip: - 10.0.0.0/8 - 192.168.0.0/16 - ip_protocol: icmp from_port: -1 to_port: -1 source_group_name: mysecgroup - ip_protocol: tcp from_port: 8080 to_port: 8080 source_group_name: MyOtherSecGroup source_group_name_vpc: MyPeeredVPC - rules_egress: - ip_protocol: all from_port: -1 to_port: -1 cidr_ip: - 10.0.0.0/8 - 192.168.0.0/16 - tags: SomeTag: 'My Tag Value' SomeOtherTag: 'Other Tag Value' - region: us-east-1 - keyid: GKTADJGHEIQSXMKKRBJ08H - key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs # Using a profile from pillars Ensure mysecgroup exists: boto_secgroup.present: - name: mysecgroup - description: My security group - profile: myprofile # Passing in a profile Ensure mysecgroup exists: boto_secgroup.present: - name: mysecgroup - description: My security group - profile: keyid: GKTADJGHEIQSXMKKRBJ08H key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs region: us-east-1 .. note:: When using the ``profile`` parameter and ``region`` is set outside of the profile group, region is ignored and a default region will be used. If ``region`` is missing from the ``profile`` data set, ``us-east-1`` will be used as the default region. � N)�SaltInvocationErrorc C s dt v rdS dS )z) Only load if boto is available. �boto_secgroup.existsZ boto_secgroup)Fz(boto_secgroup module could not be loaded)�__salt__� r r �M/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/boto_secgroup.py�__virtual__s s r Tc C s� | ddi d�} t | ||||| | |d�}|d | d<