VpcLookupOptions

class aws_cdk.aws_ec2.VpcLookupOptions(*, is_default=None, owner_account_id=None, region=None, return_vpn_gateways=None, subnet_group_name_tag=None, tags=None, vpc_id=None, vpc_name=None)

Bases: object

Properties for looking up an existing VPC.

The combination of properties must specify filter down to exactly one non-default VPC, otherwise an error is raised.

Parameters:
  • is_default (Optional[bool]) – Whether to match the default VPC. Default: Don’t care whether we return the default VPC

  • owner_account_id (Optional[str]) – The ID of the AWS account that owns the VPC. Default: the account id of the parent stack

  • region (Optional[str]) – Optional to override inferred region. Default: Current stack’s environment region

  • return_vpn_gateways (Optional[bool]) – Whether to look up whether a VPN Gateway is attached to the looked up VPC. You can set this to false if you know the VPC does not have a VPN Gateway attached, in order to avoid an API call. If you change this property from false to true or undefined, you may need to clear the corresponding context entry in cdk.context.json in order to trigger a new lookup. Default: true

  • subnet_group_name_tag (Optional[str]) – Optional tag for subnet group name. If not provided, we’ll look at the aws-cdk:subnet-name tag. If the subnet does not have the specified tag, we’ll use its type as the name. Default: aws-cdk:subnet-name

  • tags (Optional[Mapping[str, str]]) – Tags on the VPC. The VPC must have all of these tags Default: Don’t filter on tags

  • vpc_id (Optional[str]) – The ID of the VPC. If given, will import exactly this VPC. Default: Don’t filter on vpcId

  • vpc_name (Optional[str]) – The name of the VPC. If given, will import the VPC with this name. Default: Don’t filter on vpcName

ExampleMetadata:

infused

Example:

vpc = ec2.Vpc.from_lookup(self, "Vpc",
    is_default=True
)
cluster = ecs.Cluster(self, "ECSCluster", vpc=vpc)

task_definition = ecs.TaskDefinition(self, "TD",
    compatibility=ecs.Compatibility.EC2
)

task_definition.add_container("TheContainer",
    image=ecs.ContainerImage.from_registry("foo/bar"),
    memory_limit_mi_b=256
)

run_task = tasks.EcsRunTask(self, "Run",
    integration_pattern=sfn.IntegrationPattern.RUN_JOB,
    cluster=cluster,
    task_definition=task_definition,
    launch_target=tasks.EcsEc2LaunchTarget(),
    enable_execute_command=True
)

Attributes

is_default

Whether to match the default VPC.

Default:

Don’t care whether we return the default VPC

owner_account_id

The ID of the AWS account that owns the VPC.

Default:

the account id of the parent stack

region

Optional to override inferred region.

Default:

Current stack’s environment region

return_vpn_gateways

Whether to look up whether a VPN Gateway is attached to the looked up VPC.

You can set this to false if you know the VPC does not have a VPN Gateway attached, in order to avoid an API call.

If you change this property from false to true or undefined, you may need to clear the corresponding context entry in cdk.context.json in order to trigger a new lookup.

Default:

true

subnet_group_name_tag

Optional tag for subnet group name.

If not provided, we’ll look at the aws-cdk:subnet-name tag. If the subnet does not have the specified tag, we’ll use its type as the name.

Default:

aws-cdk:subnet-name

tags

Tags on the VPC.

The VPC must have all of these tags

Default:

Don’t filter on tags

vpc_id

The ID of the VPC.

If given, will import exactly this VPC.

Default:

Don’t filter on vpcId

vpc_name

The name of the VPC.

If given, will import the VPC with this name.

Default:

Don’t filter on vpcName