> **Experimental**
>
> `@aws-cdk/aws-imagebuilder-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# InfrastructureConfiguration

Represents an EC2 Image Builder Infrastructure Configuration.

Extends: Construct › Resource › InfrastructureConfiguration
Implements: IInfrastructureConfiguration, IResource, IEnvironmentAware, IConstruct, IDependable

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/infrastructure-configuration.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0-alpha.0/packages/@aws-cdk/aws-imagebuilder-alpha/lib/infrastructure-configuration.ts#L327)

## Example

```ts
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
});
```

## Initializer

```ts
new InfrastructureConfiguration(scope: Construct, id: string, props?: InfrastructureConfigurationProps)
```

## Construct Props

- `description`: string = None — The description of the infrastructure configuration.

- `ec2InstanceAvailabilityZone`: string — The availability zone to place Image Builder build and test EC2 instances.

  **Default:** EC2 will select a random zone

- `ec2InstanceHostId`: string = None — The ID of the Dedicated Host on which build and test instances run.

  This only applies if the instance tenancy is
  `host`. This cannot be used with the `ec2InstanceHostResourceGroupArn` parameter.

- `ec2InstanceHostResourceGroupArn`: string = None — The ARN of the host resource group on which build and test instances run.

  This only applies if the instance tenancy
  is `host`. This cannot be used with the `ec2InstanceHostId` parameter.

- `ec2InstanceTenancy`: [Tenancy](/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.Tenancy.html) = Tenancy.DEFAULT — The tenancy of the instance.

  Dedicated tenancy runs instances on single-tenant hardware, while host tenancy runs
  instances on a dedicated host. Shared tenancy is used by default.

- `httpPutResponseHopLimit`: number = 2 — The maximum number of hops that an instance metadata request can traverse to reach its destination.

  By default,
  this is set to 2.

- `httpTokens`: [HttpTokens](/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.HttpTokens.html) = HttpTokens.REQUIRED — Indicates whether a signed token header is required for instance metadata retrieval requests.

  By default, this is
  set to `required` to require IMDSv2 on build and test EC2 instances.

- `infrastructureConfigurationName`: string — The name of the infrastructure configuration.

  **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.

- `instanceProfile`: [IInstanceProfile](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IInstanceProfile.html) — The instance profile to associate with the instance used to customize the AMI.

  **Default:** An instance profile will be generated

  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.

- `instanceTypes`: [InstanceType](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html)[] — The instance types to launch build and test EC2 instances with.

  **Default:** Image Builder will choose from a default set of instance types compatible with the AMI

- `keyPair`: [IKeyPair](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IKeyPair.html) = None — The key pair used to connect to the build and test EC2 instances.

  The key pair can be used to log into the build
  or test instances for troubleshooting any failures.

- `logging`: [InfrastructureConfigurationLogging](/cdk/api/v2/docs/@aws-cdk_aws-imagebuilder-alpha.InfrastructureConfigurationLogging.html) = None — The log settings for detailed build logging.

- `notificationTopic`: [ITopic](/cdk/api/v2/docs/aws-cdk-lib.aws_sns.ITopic.html) — The SNS topic on which notifications are sent when an image build completes.

  **Default:** No notifications are sent

- `resourceTags`: { [key: string]: string } = None — The additional tags to assign to the Amazon EC2 instance that Image Builder launches during the build process.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — An IAM role to associate with the instance profile used by Image Builder.

  **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.

  ```ts
  const instanceProfileRole = new iam.Role(this, 'MyRole', {
    assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
  });
  ```

- `securityGroups`: [ISecurityGroup](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — The security groups to associate with the instance used to customize the AMI.

  **Default:** The default security group for the VPC will be used

- `subnetSelection`: [SubnetSelection](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Select which subnet to place the instance used to customize the AMI.

  **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 } = None — The tags to apply to the infrastructure configuration.

- `terminateInstanceOnFailure`: boolean = true — Whether to terminate the EC2 instance when the build or test workflow fails.

- `vpc`: [IVpc](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) — The VPC to place the instance used to customize the AMI.

  **Default:** The default VPC will be used

## Properties

- `env`: [ResourceEnvironment](/cdk/api/v2/docs/aws-cdk-lib.interfaces.ResourceEnvironment.html) — The environment this resource belongs to.

  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.

- `infrastructureConfigurationArn`: string — The ARN of the infrastructure configuration.

- `infrastructureConfigurationName`: string — The name of the infrastructure configuration.

- `instanceProfile`: [IInstanceProfile](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IInstanceProfile.html) — The EC2 instance profile to use for the build.

- `logBucket`: [IBucket](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.IBucket.html) — The bucket used to upload image build logs.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `PROPERTY_INJECTION_ID`: string (static) — Uniquely identifies this class.

- `role`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The role associated with the EC2 instance profile used for the build.

- `stack`: [Stack](/cdk/api/v2/docs/aws-cdk-lib.Stack.html) — The stack in which this resource is defined.

## Methods

- `applyCrossStackReferenceStrength(strength: ReferenceStrength): void` — Override the cross-stack reference strength for this resource.

  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**

  - `strength` — - The reference strength to use for this resource.

- `applyRemovalPolicy(policy: RemovalPolicy): void` — Apply the given removal policy to this resource.

  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` (static) — Import an existing infrastructure configuration given its ARN.

- `fromInfrastructureConfigurationName(scope: Construct, id: string, infrastructureConfigurationName: string): IInfrastructureConfiguration` (static) — Import an existing infrastructure configuration given its name.

  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[]): Grant` — Grant custom actions to the given grantee for the infrastructure configuration [disable-awslint:no-grants].

  **Parameters**

  - `grantee` — - The principal.
  - `actions` — - The list of actions.

- `grantRead(grantee: IGrantable): Grant` — Grant read permissions to the given grantee for the infrastructure configuration [disable-awslint:no-grants].

  **Parameters**

  - `grantee` — - The principal.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  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**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `isInfrastructureConfiguration(x: any): boolean` (static) — Return whether the given object is an InfrastructureConfiguration.

- `isOwnedResource(construct: IConstruct): boolean` (static) — Returns true if the construct was created by CDK, and false otherwise.

- `isResource(construct: IConstruct): boolean` (static) — Check whether the given construct is a Resource.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  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.
