Experimental
@aws-cdk/aws-apprunner-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
VpcConnectorProps Struct
Properties of the AppRunner VPC Connector.
| Stability | Experimental |
|---|---|
| Source | lib/vpc-connector.ts |
Example
ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';
const vpc = new ec2.Vpc(this, 'Vpc', {
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16')
});
const vpcConnector = new apprunner.VpcConnector(this, 'VpcConnector', {
vpc,
vpcSubnets: vpc.selectSubnets({ subnetType: ec2.SubnetType.PUBLIC }),
vpcConnectorName: 'MyVpcConnector',
});
new apprunner.Service(this, 'Service', {
source: apprunner.Source.fromEcrPublic({
imageConfiguration: { port: 8000 },
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
}),
vpcConnector,
});
python
import aws_cdk.aws_ec2 as ec2
vpc = ec2.Vpc(self, "Vpc",
ip_addresses=ec2.IpAddresses.cidr("10.0.0.0/16")
)
vpc_connector = apprunner.VpcConnector(self, "VpcConnector",
vpc=vpc,
vpc_subnets=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC),
vpc_connector_name="MyVpcConnector"
)
apprunner.Service(self, "Service",
source=apprunner.Source.from_ecr_public(
image_configuration=apprunner.ImageConfiguration(port=8000),
image_identifier="public.ecr.aws/aws-containers/hello-app-runner:latest"
),
vpc_connector=vpc_connector
)
java
import software.amazon.awscdk.services.ec2.*;
Vpc vpc = Vpc.Builder.create(this, "Vpc")
.ipAddresses(IpAddresses.cidr("10.0.0.0/16"))
.build();
VpcConnector vpcConnector = VpcConnector.Builder.create(this, "VpcConnector")
.vpc(vpc)
.vpcSubnets(vpc.selectSubnets(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build()))
.vpcConnectorName("MyVpcConnector")
.build();
Service.Builder.create(this, "Service")
.source(Source.fromEcrPublic(EcrPublicProps.builder()
.imageConfiguration(ImageConfiguration.builder().port(8000).build())
.imageIdentifier("public.ecr.aws/aws-containers/hello-app-runner:latest")
.build()))
.vpcConnector(vpcConnector)
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.AppRunner.Alpha
using Amazon.CDK.AWS.EC2;
var vpc = new Vpc(this, "Vpc", new VpcProps {
IpAddresses = IpAddresses.Cidr("10.0.0.0/16")
});
var vpcConnector = new VpcConnector(this, "VpcConnector", new VpcConnectorProps {
Vpc = vpc,
VpcSubnets = vpc.SelectSubnets(new SubnetSelection { SubnetType = SubnetType.PUBLIC }),
VpcConnectorName = "MyVpcConnector"
});
new Service(this, "Service", new ServiceProps {
Source = Source.FromEcrPublic(new EcrPublicProps {
ImageConfiguration = new ImageConfiguration { Port = 8000 },
ImageIdentifier = "public.ecr.aws/aws-containers/hello-app-runner:latest"
}),
VpcConnector = vpcConnector
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkapprunneralpha/v2
import "github.com/aws/aws-cdk-go/awscdk"
vpc := ec2.NewVpc(this, jsii.String("Vpc"), &VpcProps{
IpAddresses: ec2.IpAddresses_Cidr(jsii.String("10.0.0.0/16")),
})
vpcConnector := apprunner.NewVpcConnector(this, jsii.String("VpcConnector"), &VpcConnectorProps{
Vpc: Vpc,
VpcSubnets: vpc.selectSubnets(&SubnetSelection{
SubnetType: ec2.SubnetType_PUBLIC,
}),
VpcConnectorName: jsii.String("MyVpcConnector"),
})
apprunner.NewService(this, jsii.String("Service"), &ServiceProps{
Source: apprunner.Source_FromEcrPublic(&EcrPublicProps{
ImageConfiguration: &ImageConfiguration{
Port: jsii.Number(8000),
},
ImageIdentifier: jsii.String("public.ecr.aws/aws-containers/hello-app-runner:latest"),
}),
VpcConnector: VpcConnector,
})
Properties
securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup #A list of IDs of security groups that App Runner should use for access to AWS resources under the specified subnets.
Default: a new security group will be created in the specified VPC
vpcConnectorNameoptionalstringvpc_connector_nameoptionalstrvpcConnectorNameoptionalStringVpcConnectorNameoptionalstringVpcConnectorNameoptional*string #The name for the VpcConnector.
Default: a name generated by CloudFormation
vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection #Where to place the VPC Connector within the VPC.
Default: Private subnets.