pcf.particle.aws.vpc package

Submodules

pcf.particle.aws.vpc.subnet module

class pcf.particle.aws.vpc.subnet.Subnet(particle_definition)

Bases: pcf.core.aws_resource.AWSResource

This is the implementation of Amazon’s Subnet resource.

START_PARAMS = {'AvailabilityZone', 'CidrBlock', 'Ipv6CidrBlock', 'VpcId'}
UNIQUE_KEYS = ['aws_resource.custom_config.subnet_name']
_get_subnet_client()

Creates a new subnet_client

Returns:subnet_client
_set_unique_keys()

Logic that sets keys from state definition that are used to uniquely identify the subnet

_start()

Creates subnet and adds tag for PCFName. The VpcId field or a parent vpc particle is required.

Returns:boto3 create_subnet() response
_stop()

Calls _terminate()

_terminate()

Calls boto3 delete_subnet()

Returns:boto3 delete_subnet() response
_update()

No updates available

equivalent_states = {<State.running: 1>: 1, <State.stopped: 2>: 0, <State.terminated: 3>: 0}
flavor = 'subnet'
get_status()

Calls boto3 describe_subnets().

Returns:“missing”}
Return type:status or {“status”
is_state_definition_equivalent()

Since there is no update available for subnet this always returns True

Returns:bool
is_state_equivalent(state1, state2)
Parameters:
Returns:

bool

state_lookup = {'available': <State.running: 1>, 'missing': <State.terminated: 3>, 'pending': <State.pending: 4>}
subnet_client

The Subnet client. Calls _get_subnet_client to create a new client if needed

Returns:subnet_client
sync_state()

Calls get_status() and updates the current_state_definition and the state.

pcf.particle.aws.vpc.security_group module

class pcf.particle.aws.vpc.security_group.SecurityGroup(particle_definition)

Bases: pcf.core.aws_resource.AWSResource

This is the implementation of Amazon’s Security Groups

DEFINITION_FILTER = {'IpPermissions', 'IpPermissionsEgress'}
START_PARAMS = {'Description', 'DryRun', 'GroupName', 'VpcId'}
UNIQUE_KEYS = ['aws_resource.GroupName']
_set_unique_keys()

Logic that sets keys from state definition that are used to uniquely identify the security group

_set_vpc_id()

Checks to see if user specified a vpc_id in the particle definition. If not the vpc_id is retrieved from it’s parent using the get_vpc_id util

_start()

Creates security group and adds the tags and rules :returns: boto3 create_security_group response (groud id)

_stop()

Calls _terminate()

_terminate()

Calls boto3 delete_security_group() :returns: boto3 delete_security_group() response

_update()

removes and adds security group rules based on the new desired definition using boto3 revoke and authorize

equivalent_states = {<State.running: 1>: 1, <State.stopped: 2>: 0, <State.terminated: 3>: 0}
flavor = 'security_group'
get_current_definition()

Calls boto3 describe_security_groups to return current definition. Returns missing if the security group doesn’t exist :returns: status or None

is_state_definition_equivalent()

Compares the desired state and current state definition and returns whether they are equivalent Only considers fields defined in the desired definition All fields not specified are left alone in the current state (excluding rules) Both rules lists must be defined even when empty

Returns:bool
is_state_equivalent(state1, state2)

Looks up state equivalents and checks if the two inputs map to the same state

Returns:bool
security_group_resource

The security group resource. Creates Boto Security Group resource for the given group id :returns: boto security group resource

state_lookup = {'available': <State.running: 1>, 'missing': <State.terminated: 3>, 'pending': <State.pending: 4>}
sync_state()

Uses get_current_definition to determine whether the group exists or not and sets the state

Returns:void

pcf.particle.aws.vpc.vpc module

class pcf.particle.aws.vpc.vpc_instance.VPCInstance(particle_definition, session=None)

Bases: pcf.core.aws_resource.AWSResource

This is the implementation of Amazon’s VPC resource.

START_PARAMS = {'AmazonProvidedIpv6CidrBlock', 'CidrBlock', 'InstanceTenancy'}
UNIQUE_KEYS = ['aws_resource.custom_config.vpc_name']
_get_vpc_client()

Creates a new vpc_client

Returns:vpc_client
_set_unique_keys()

Logic that sets keys from state definition that are used to uniquely identify the VPC

_start()

Creates vpc and adds tag for PCFName

Returns:boto3 create_vpc() response
_stop()

Calls _terminate()

_terminate()

Calls boto3 delete_vpc()

Returns:boto3 delete_vpc() response
_update()

No updates available

equivalent_states = {<State.running: 1>: 1, <State.stopped: 2>: 0, <State.terminated: 3>: 0}
flavor = 'vpc_instance'
get_status()

Calls boto3 describe_vpc using describe_vpcs().

Returns:“missing”}
Return type:status or {“status”
is_state_definition_equivalent()

Since there is no update available for vpc this always returns True

Returns:bool
is_state_equivalent(state1, state2)
Parameters:
Returns:

bool

state_lookup = {'available': <State.running: 1>, 'missing': <State.terminated: 3>, 'pending': <State.pending: 4>}
sync_state()

Calls get_status() and updates the current_state_definition and the state.

vpc_client

The VPC client. Calls _get_vpc_client to create a new client if needed

Returns:vpc_client

Module contents