This is the new CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.
AWS::ImageBuilder::InfrastructureConfiguration
Creates a new infrastructure configuration. An infrastructure configuration defines the environment in which your image will be built and tested.
Syntax
To declare this entity in your CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::ImageBuilder::InfrastructureConfiguration", "Properties" : { "Description" :String, "InstanceMetadataOptions" :InstanceMetadataOptions, "InstanceProfileName" :String, "InstanceTypes" :[ String, ... ], "KeyPair" :String, "Logging" :Logging, "Name" :String, "Placement" :Placement, "ResourceTags" :{, "SecurityGroupIds" :Key:Value, ...}[ String, ... ], "SnsTopicArn" :String, "SubnetId" :String, "Tags" :{, "TerminateInstanceOnFailure" :Key:Value, ...}Boolean} }
YAML
Type: AWS::ImageBuilder::InfrastructureConfiguration Properties: Description:StringInstanceMetadataOptions:InstanceMetadataOptionsInstanceProfileName:StringInstanceTypes:- StringKeyPair:StringLogging:LoggingName:StringPlacement:PlacementResourceTags:SecurityGroupIds:Key:Value- StringSnsTopicArn:StringSubnetId:StringTags:TerminateInstanceOnFailure:Key:ValueBoolean
Properties
Description-
The description of the infrastructure configuration.
Required: No
Type: String
Minimum:
1Maximum:
1024Update requires: No interruption
InstanceMetadataOptions-
The instance metadata service (IMDS) settings that Image Builder applies to the EC2 build and test instances it launches during image creation. If you don't set these options, the EC2 launch defaults for the instance apply. For more information about instance metadata options, see one of the following links:
-
Configure the instance metadata options in the Amazon EC2 User Guide for Linux instances.
-
Configure the instance metadata options in the Amazon EC2 Windows Guide for Windows instances.
Required: No
Type: InstanceMetadataOptions
Update requires: No interruption
-
InstanceProfileName-
The instance profile to associate with the instance used to customize your Amazon EC2 AMI. The instance profile must exist in your account.
Required: Yes
Type: String
Pattern:
^[\w+=,.@-]+$Minimum:
1Maximum:
256Update requires: No interruption
InstanceTypes-
The instance types of the infrastructure configuration. You can specify one or more instance types to use for this build. Image Builder picks one of these instance types based on availability. If you don't specify instance types, Image Builder selects compatible instance types automatically. If you specify a Dedicated Host, Image Builder uses only instance types that the host supports.
Required: No
Type: Array of String
Update requires: No interruption
KeyPair-
The key pair of the infrastructure configuration. You can use this to log on to and debug the instance used to create your image.
Required: No
Type: String
Minimum:
1Maximum:
1024Update requires: No interruption
Logging-
The logging configuration of the infrastructure configuration. When you configure S3 logs, Image Builder writes logs from the build and test process to the specified bucket under the key prefix.
Required: No
Type: Logging
Update requires: No interruption
Name-
The name of the infrastructure configuration. Infrastructure configuration names must be unique to your account in each AWS Region. Image Builder generates the infrastructure configuration ARN from a normalized form of the name, so names that differ only in case, spaces, or underscores count as the same name.
Required: Yes
Type: String
Pattern:
^[-_A-Za-z-0-9][-_A-Za-z0-9 ]{1,126}[-_A-Za-z-0-9]$Update requires: Replacement
Placement-
The instance placement settings that define where the build and test instances that Image Builder launches during image creation run. These settings don't affect instances that you launch from the output image.
Required: No
Type: Placement
Update requires: No interruption
-
The metadata tags to assign to the Amazon EC2 instance that Image Builder launches during the build process. Tags are formatted as key value pairs. Tag keys can't begin with
aws:or match one of the following reserved keys:CreatedBy,Ec2ImageBuilderArn,Name, orTags.Required: No
Type: Object of String
Pattern:
.{1,}Update requires: No interruption
SecurityGroupIds-
The security group IDs to associate with the instance used to customize your Amazon EC2 AMI.
Required: No
Type: Array of String
Update requires: No interruption
SnsTopicArn-
The Amazon Resource Name (ARN) of the SNS topic to which Image Builder sends image build event notifications. Specify a standard topic. Image Builder doesn't support FIFO topics. Image Builder validates the topic when you create or update the configuration. You must have permission to publish to the topic.
Note
EC2 Image Builder can't send notifications to SNS topics that are encrypted using keys from other accounts. If your SNS topic is encrypted, the key must be owned by the same account that owns your Image Builder resources.
Required: No
Type: String
Pattern:
^arn:aws[^:]*:sns:[^:]+:[0-9]{12}:[a-zA-Z0-9-_]{1,256}$Update requires: No interruption
SubnetId-
The subnet ID in which to place the instance used to customize your Amazon EC2 AMI. If you specify
subnetId, you must also specify one or more security group IDs insecurityGroupIds. Otherwise, the request fails.Required: No
Type: String
Minimum:
1Maximum:
1024Update requires: No interruption
-
The metadata tags to assign to the infrastructure configuration resource that Image Builder creates as output. Tags are formatted as key value pairs.
Required: No
Type: Object of String
Pattern:
.{1,}Update requires: No interruption
TerminateInstanceOnFailure-
Specifies whether to terminate the instance on failure. Set to false if you want Image Builder to retain the instance used to configure your AMI if the build or test phase of your workflow fails. Defaults to
true.Required: No
Type: Boolean
Update requires: No interruption
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource ARN, such as
arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure.
For more information about using the Ref function, see Ref.
Fn::GetAtt
The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.
Arn-
Returns the Amazon Resource Name (ARN) of the infrastructure configuration. For example,
arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/myexampleinfrastructure. Name-
The name of the infrastructure configuration.
Examples
Create an infrastructure configuration
The following example shows the template for the InfrastructureConfiguration resource in both JSON and YAML format.
JSON
{ "Resources": { "InfrastructureConfigurationAll": { "Type": "AWS::ImageBuilder::InfrastructureConfiguration", "Properties": { "Name": "infrastructure-configuration-name", "InstanceProfileName": "instance-profile-name", "Description": "description", "InstanceTypes": [ "m4.large", "m5.large" ], "KeyPair": "key-pair", "Logging": { "S3Logs": { "S3BucketName": "imagebuilder-logging-bucket", "S3KeyPrefix": "imagebuilder-bucket-prefix" } }, "SnsTopicArn": { "Ref": "SnsTopicArn" }, "TerminateInstanceOnFailure": true, "SecurityGroupIds": [ "security-group-id-1", "security-group-id-2" ], "SubnetId": "subnet-id", "Tags": { "CustomerInfraConfigTagKey1": "CustomerInfraConfigTagValue1", "CustomerInfraConfigTagKey2": "CustomerInfraConfigTagValue2" } } } } }
YAML
Resources: InfrastructureConfigurationAll: Type: 'AWS::ImageBuilder::InfrastructureConfiguration' Properties: Name: 'infrastructure-configuration-name' InstanceProfileName: 'instance-profile-name' Description: 'description' InstanceTypes: - 'm4.large' - 'm5.large' KeyPair: 'key-pair' Logging: S3Logs: S3BucketName: 'imagebuilder-logging-bucket' S3KeyPrefix: 'imagebuilder-bucket-prefix' SnsTopicArn: !Ref SnsTopicArn TerminateInstanceOnFailure: true SecurityGroupIds: - 'security-group-id-1' - 'security-group-id-2' SubnetId: 'subnet-id' Tags: CustomerInfraConfigTagKey1: 'CustomerInfraConfigTagValue1' CustomerInfraConfigTagKey2: 'CustomerInfraConfigTagValue2'
Create an infrastructure configuration with placement and metadata options
The following example creates an infrastructure configuration that uses dedicated tenancy and requires Instance Metadata Service Version 2 (IMDSv2) tokens. The configuration also applies resource tags to the build instance.
YAML
Resources: InfraConfigAdvanced: Type: AWS::ImageBuilder::InfrastructureConfiguration Properties: Name: infra-config-advanced InstanceProfileName: !Ref ImageBuilderInstanceProfile InstanceTypes: - m5.large - m5.xlarge SubnetId: !Ref PrivateSubnet SecurityGroupIds: - !Ref BuildSecurityGroup Placement: Tenancy: dedicated AvailabilityZone: us-west-2a InstanceMetadataOptions: HttpTokens: required HttpPutResponseHopLimit: 2 ResourceTags: CostCenter: imaging Environment: build TerminateInstanceOnFailure: true Logging: S3Logs: S3BucketName: !Ref LogBucket S3KeyPrefix: image-builder/logs
JSON
{ "Resources": { "InfraConfigAdvanced": { "Type": "AWS::ImageBuilder::InfrastructureConfiguration", "Properties": { "Name": "infra-config-advanced", "InstanceProfileName": { "Ref": "ImageBuilderInstanceProfile" }, "InstanceTypes": ["m5.large", "m5.xlarge"], "SubnetId": { "Ref": "PrivateSubnet" }, "SecurityGroupIds": [ { "Ref": "BuildSecurityGroup" } ], "Placement": { "Tenancy": "dedicated", "AvailabilityZone": "us-west-2a" }, "InstanceMetadataOptions": { "HttpTokens": "required", "HttpPutResponseHopLimit": 2 }, "ResourceTags": { "CostCenter": "imaging", "Environment": "build" }, "TerminateInstanceOnFailure": true, "Logging": { "S3Logs": { "S3BucketName": { "Ref": "LogBucket" }, "S3KeyPrefix": "image-builder/logs" } } } } } }
See also
-
Manage infrastructure configurations in the Image Builder User Guide.