Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
InfrastructureConfiguration L2 construct
Represents an EC2 Image Builder Infrastructure Configuration.
Example
const infrastructureConfiguration = new imagebuilder.InfrastructureConfiguration(this, 'Infrastructure', {
infrastructureConfigurationName: 'production-infrastructure',
instanceTypes: [
ec2.InstanceType.of(ec2.InstanceClass.COMPUTE7_INTEL, ec2.InstanceSize.LARGE)
],
vpc: vpc,
subnetSelection: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS }
});
const distributionConfiguration = new imagebuilder.DistributionConfiguration(this, 'Distribution');
distributionConfiguration.addAmiDistributions({
amiName: 'production-ami-{{ imagebuilder:buildDate }}',
amiTargetAccountIds: ['123456789012', '098765432109']
});
const productionPipeline = new imagebuilder.ImagePipeline(this, 'ProductionPipeline', {
recipe: exampleImageRecipe,
infrastructureConfiguration: infrastructureConfiguration,
distributionConfiguration: distributionConfiguration
});
infrastructure_configuration = imagebuilder.InfrastructureConfiguration(self, "Infrastructure",
infrastructure_configuration_name="production-infrastructure",
instance_types=[
ec2.InstanceType.of(ec2.InstanceClass.COMPUTE7_INTEL, ec2.InstanceSize.LARGE)
],
vpc=vpc,
subnet_selection=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS)
)
distribution_configuration = imagebuilder.DistributionConfiguration(self, "Distribution")
distribution_configuration.add_ami_distributions(
ami_name="production-ami-{{ imagebuilder:buildDate }}",
ami_target_account_ids=["123456789012", "098765432109"]
)
production_pipeline = imagebuilder.ImagePipeline(self, "ProductionPipeline",
recipe=example_image_recipe,
infrastructure_configuration=infrastructure_configuration,
distribution_configuration=distribution_configuration
)
InfrastructureConfiguration infrastructureConfiguration = InfrastructureConfiguration.Builder.create(this, "Infrastructure")
.infrastructureConfigurationName("production-infrastructure")
.instanceTypes(List.of(InstanceType.of(InstanceClass.COMPUTE7_INTEL, InstanceSize.LARGE)))
.vpc(vpc)
.subnetSelection(SubnetSelection.builder().subnetType(SubnetType.PRIVATE_WITH_EGRESS).build())
.build();
DistributionConfiguration distributionConfiguration = new DistributionConfiguration(this, "Distribution");
distributionConfiguration.addAmiDistributions(AmiDistribution.builder()
.amiName("production-ami-{{ imagebuilder:buildDate }}")
.amiTargetAccountIds(List.of("123456789012", "098765432109"))
.build());
ImagePipeline productionPipeline = ImagePipeline.Builder.create(this, "ProductionPipeline")
.recipe(exampleImageRecipe)
.infrastructureConfiguration(infrastructureConfiguration)
.distributionConfiguration(distributionConfiguration)
.build();
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var infrastructureConfiguration = new InfrastructureConfiguration(this, "Infrastructure", new InfrastructureConfigurationProps {
InfrastructureConfigurationName = "production-infrastructure",
InstanceTypes = new [] { InstanceType.Of(InstanceClass.COMPUTE7_INTEL, InstanceSize.LARGE) },
Vpc = vpc,
SubnetSelection = new SubnetSelection { SubnetType = SubnetType.PRIVATE_WITH_EGRESS }
});
var distributionConfiguration = new DistributionConfiguration(this, "Distribution");
distributionConfiguration.AddAmiDistributions(new AmiDistribution {
AmiName = "production-ami-{{ imagebuilder:buildDate }}",
AmiTargetAccountIds = new [] { "123456789012", "098765432109" }
});
var productionPipeline = new ImagePipeline(this, "ProductionPipeline", new ImagePipelineProps {
Recipe = exampleImageRecipe,
InfrastructureConfiguration = infrastructureConfiguration,
DistributionConfiguration = distributionConfiguration
});
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
infrastructureConfiguration := imagebuilder.NewInfrastructureConfiguration(this, jsii.String("Infrastructure"), &InfrastructureConfigurationProps{
InfrastructureConfigurationName: jsii.String("production-infrastructure"),
InstanceTypes: []InstanceType{
ec2.InstanceType_*Of(ec2.InstanceClass_COMPUTE7_INTEL, ec2.InstanceSize_LARGE),
},
Vpc: vpc,
SubnetSelection: &SubnetSelection{
SubnetType: ec2.SubnetType_PRIVATE_WITH_EGRESS,
},
})
distributionConfiguration := imagebuilder.NewDistributionConfiguration(this, jsii.String("Distribution"))
distributionConfiguration.AddAmiDistributions(&AmiDistribution{
AmiName: jsii.String("production-ami-{{ imagebuilder:buildDate }}"),
AmiTargetAccountIds: []*string{
jsii.String("123456789012"),
jsii.String("098765432109"),
},
})
productionPipeline := imagebuilder.NewImagePipeline(this, jsii.String("ProductionPipeline"), &ImagePipelineProps{
Recipe: exampleImageRecipe,
InfrastructureConfiguration: infrastructureConfiguration,
DistributionConfiguration: distributionConfiguration,
})
Initializer
new InfrastructureConfiguration(scope: Construct, id: string, props?: InfrastructureConfigurationProps)
InfrastructureConfiguration(scope: Construct, id: str, props: typing.Optional[InfrastructureConfigurationProps] = None)
new InfrastructureConfiguration(Construct scope, String id, InfrastructureConfigurationProps props)
new InfrastructureConfiguration(Construct scope, string id, InfrastructureConfigurationProps? props = null)
NewInfrastructureConfiguration(Scope Construct, Id *string, Props InfrastructureConfigurationProps)
Construct Props
ec2InstanceAvailabilityZonestringec2_instance_availability_zonestrec2InstanceAvailabilityZoneStringEc2InstanceAvailabilityZonestringEc2InstanceAvailabilityZone*string#Default: EC2 will select a random zone
ec2InstanceHostIdstringec2_instance_host_idstrec2InstanceHostIdStringEc2InstanceHostIdstringEc2InstanceHostId*string= None#This only applies if the instance tenancy is host. This cannot be used with the ec2InstanceHostResourceGroupArn parameter.
ec2InstanceHostResourceGroupArnstringec2_instance_host_resource_group_arnstrec2InstanceHostResourceGroupArnStringEc2InstanceHostResourceGroupArnstringEc2InstanceHostResourceGroupArn*string= None#This only applies if the instance tenancy is host. This cannot be used with the ec2InstanceHostId parameter.
ec2InstanceTenancyTenancyec2_instance_tenancyTenancyec2InstanceTenancyTenancyEc2InstanceTenancyTenancyEc2InstanceTenancyTenancy= Tenancy.DEFAULT#Dedicated tenancy runs instances on single-tenant hardware, while host tenancy runs instances on a dedicated host. Shared tenancy is used by default.
httpPutResponseHopLimitnumberhttp_put_response_hop_limitint | floathttpPutResponseHopLimitNumberHttpPutResponseHopLimitdoubleHttpPutResponseHopLimit*float64= 2#By default, this is set to 2.
httpTokensHttpTokenshttp_tokensHttpTokenshttpTokensHttpTokensHttpTokensHttpTokensHttpTokensHttpTokens= HttpTokens.REQUIRED#By default, this is set to required to require IMDSv2 on build and test EC2 instances.
infrastructureConfigurationNamestringinfrastructure_configuration_namestrinfrastructureConfigurationNameStringInfrastructureConfigurationNamestringInfrastructureConfigurationName*string#Default: A name is generated
This name must be normalized by transforming all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
instanceProfileIInstanceProfileinstance_profileIInstanceProfileinstanceProfileIInstanceProfileInstanceProfileIInstanceProfileInstanceProfileIInstanceProfile#Default: An instance profile will be generated
notes
By default, an instance profile and role will be created with minimal permissions needed to build the image, attached to the EC2 instance.
If an S3 logging bucket and key prefix is provided, an IAM inline policy will be attached to the instance profile's role, allowing s3:PutObject permissions on the bucket.
instanceTypesInstanceType[]instance_typestyping.List[InstanceType]instanceTypesList<InstanceType>InstanceTypesInstanceType[]InstanceTypes*[]InstanceType#Default: Image Builder will choose from a default set of instance types compatible with the AMI
The key pair can be used to log into the build or test instances for troubleshooting any failures.
loggingInfrastructureConfigurationLoggingloggingInfrastructureConfigurationLoggingloggingInfrastructureConfigurationLoggingLoggingInfrastructureConfigurationLoggingLoggingInfrastructureConfigurationLogging= None#notificationTopicITopicnotification_topicITopicnotificationTopicITopicNotificationTopicITopicNotificationTopicITopic#Default: No notifications are sent
resourceTags{ [key: string]: string }resource_tagstyping.Mapping[str, str]resourceTagsMap<String, String>ResourceTagsIDictionary<string, string>ResourceTags*map[string]*string= None#Default: A role will automatically be created, it can be accessed via the role property
The role must be assumable by the service principal ec2.amazonaws.com: Note: You can provide an instanceProfile or a role, but not both.
example
const instanceProfileRole = new iam.Role(this, 'MyRole', {
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
});
securityGroupsISecurityGroup[]security_groupstyping.List[ISecurityGroup]securityGroupsList<ISecurityGroup>SecurityGroupsISecurityGroup[]SecurityGroups*[]ISecurityGroup#Default: The default security group for the VPC will be used
subnetSelectionSubnetSelectionsubnet_selectionSubnetSelectionsubnetSelectionSubnetSelectionSubnetSelectionSubnetSelectionSubnetSelectionSubnetSelection#Default: The first subnet selected from the provided VPC will be used
The first subnet that is selected will be used. You must specify the VPC to customize the subnet selection.
tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#terminateInstanceOnFailurebooleanterminate_instance_on_failureboolterminateInstanceOnFailureBooleanTerminateInstanceOnFailureboolTerminateInstanceOnFailure*bool= true#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
infrastructureConfigurationArnstringinfrastructure_configuration_arnstrinfrastructureConfigurationArnStringInfrastructureConfigurationArnstringInfrastructureConfigurationArn*stringrequired#infrastructureConfigurationNamestringinfrastructure_configuration_namestrinfrastructureConfigurationNameStringInfrastructureConfigurationNamestringInfrastructureConfigurationName*stringrequired#instanceProfileIInstanceProfileinstance_profileIInstanceProfileinstanceProfileIInstanceProfileInstanceProfileIInstanceProfileInstanceProfileIInstanceProfilerequired#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromInfrastructureConfigurationArn(scope: Construct, id: string, infrastructureConfigurationArn: string): IInfrastructureConfiguration@staticmethod def from_infrastructure_configuration_arn(scope: Construct, id: str, infrastructure_configuration_arn: str) -> IInfrastructureConfigurationpublic static IInfrastructureConfiguration fromInfrastructureConfigurationArn(Construct scope, String id, String infrastructureConfigurationArn)public static IInfrastructureConfiguration FromInfrastructureConfigurationArn(Construct scope, string id, string infrastructureConfigurationArn)func FromInfrastructureConfigurationArn(Scope Construct, Id *string, InfrastructureConfigurationArn *string) IInfrastructureConfigurationstatic#fromInfrastructureConfigurationName(scope: Construct, id: string, infrastructureConfigurationName: string): IInfrastructureConfiguration@staticmethod def from_infrastructure_configuration_name(scope: Construct, id: str, infrastructure_configuration_name: str) -> IInfrastructureConfigurationpublic static IInfrastructureConfiguration fromInfrastructureConfigurationName(Construct scope, String id, String infrastructureConfigurationName)public static IInfrastructureConfiguration FromInfrastructureConfigurationName(Construct scope, string id, string infrastructureConfigurationName)func FromInfrastructureConfigurationName(Scope Construct, Id *string, InfrastructureConfigurationName *string) IInfrastructureConfigurationstatic#The provided name must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#2 parameters
Parameters
granteegranteegranteegranteeGrantee— - The principal.actionsactionsactionsactionsActions— - The list of actions.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#1 parameter
Parameters
granteegranteegranteegranteeGrantee— - The principal.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isInfrastructureConfiguration(x: any): boolean@staticmethod def is_infrastructure_configuration(x: Any) -> boolpublic static Boolean isInfrastructureConfiguration(Object x)public static bool IsInfrastructureConfiguration(object x)func IsInfrastructureConfiguration(X interface{}) *boolstatic#isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.