VpcLookupOptions

class aws_cdk.aws_ec2.VpcLookupOptions(*, is_default=None, region=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

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

  • 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, "FargateCluster", vpc=vpc)

task_definition = ecs.TaskDefinition(self, "TD",
    memory_mi_b="512",
    cpu="256",
    compatibility=ecs.Compatibility.FARGATE
)

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

run_task = tasks.EcsRunTask(self, "RunFargate",
    integration_pattern=sfn.IntegrationPattern.RUN_JOB,
    cluster=cluster,
    task_definition=task_definition,
    assign_public_ip=True,
    container_overrides=[tasks.ContainerOverride(
        container_definition=container_definition,
        environment=[tasks.TaskEnvironmentVariable(name="SOME_KEY", value=sfn.JsonPath.string_at("$.SomeKey"))]
    )],
    launch_target=tasks.EcsFargateLaunchTarget()
)

Attributes

is_default

Whether to match the default VPC.

Default

Don’t care whether we return the default VPC

Return type

Optional[bool]

region

Optional to override inferred region.

Default

Current stack’s environment region

Return type

Optional[str]

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

Return type

Optional[str]

tags

Tags on the VPC.

The VPC must have all of these tags

Default

Don’t filter on tags

Return type

Optional[Mapping[str, str]]

vpc_id

The ID of the VPC.

If given, will import exactly this VPC.

Default

Don’t filter on vpcId

Return type

Optional[str]

vpc_name

The name of the VPC.

If given, will import the VPC with this name.

Default

Don’t filter on vpcName

Return type

Optional[str]