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

Properties for an EC2 Image Builder image.

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/image.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-imagebuilder-alpha/lib/image.ts#L201)

## Example

TypeScript:

```ts
// Import by name
const existingImageByName = imagebuilder.Image.fromImageName(
  this,
  'ExistingImageByName',
  'my-existing-image'
);

// Import by ARN
const existingImageByArn = imagebuilder.Image.fromImageArn(
  this,
  'ExistingImageByArn',
  'arn:aws:imagebuilder:us-east-1:123456789012:image/imported-image/1.0.0'
);

// Import by attributes
const existingImageByAttributes = imagebuilder.Image.fromImageAttributes(this, 'ExistingImageByAttributes', {
  imageName: 'shared-base-image',
  imageVersion: '2024.11.25'
});

// Grant permissions to imported images
const role = new iam.Role(this, 'ImageAccessRole', {
  assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com')
});

existingImageByName.grantRead(role);
existingImageByArn.grant(role, 'imagebuilder:GetImage', 'imagebuilder:ListImagePackages');
```

Python:

```python
# Import by name
existing_image_by_name = imagebuilder.Image.from_image_name(self, "ExistingImageByName", "my-existing-image")

# Import by ARN
existing_image_by_arn = imagebuilder.Image.from_image_arn(self, "ExistingImageByArn", "arn:aws:imagebuilder:us-east-1:123456789012:image/imported-image/1.0.0")

# Import by attributes
existing_image_by_attributes = imagebuilder.Image.from_image_attributes(self, "ExistingImageByAttributes",
    image_name="shared-base-image",
    image_version="2024.11.25"
)

# Grant permissions to imported images
role = iam.Role(self, "ImageAccessRole",
    assumed_by=iam.ServicePrincipal("lambda.amazonaws.com")
)

existing_image_by_name.grant_read(role)
existing_image_by_arn.grant(role, "imagebuilder:GetImage", "imagebuilder:ListImagePackages")
```

Java:

```java
// Import by name
IImage existingImageByName = Image.fromImageName(this, "ExistingImageByName", "my-existing-image");

// Import by ARN
IImage existingImageByArn = Image.fromImageArn(this, "ExistingImageByArn", "arn:aws:imagebuilder:us-east-1:123456789012:image/imported-image/1.0.0");

// Import by attributes
IImage existingImageByAttributes = Image.fromImageAttributes(this, "ExistingImageByAttributes", ImageAttributes.builder()
        .imageName("shared-base-image")
        .imageVersion("2024.11.25")
        .build());

// Grant permissions to imported images
Role role = Role.Builder.create(this, "ImageAccessRole")
        .assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
        .build();

existingImageByName.grantRead(role);
existingImageByArn.grant(role, "imagebuilder:GetImage", "imagebuilder:ListImagePackages");
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
// Import by name
var existingImageByName = Image.FromImageName(this, "ExistingImageByName", "my-existing-image");

// Import by ARN
var existingImageByArn = Image.FromImageArn(this, "ExistingImageByArn", "arn:aws:imagebuilder:us-east-1:123456789012:image/imported-image/1.0.0");

// Import by attributes
var existingImageByAttributes = Image.FromImageAttributes(this, "ExistingImageByAttributes", new ImageAttributes {
    ImageName = "shared-base-image",
    ImageVersion = "2024.11.25"
});

// Grant permissions to imported images
var role = new Role(this, "ImageAccessRole", new RoleProps {
    AssumedBy = new ServicePrincipal("lambda.amazonaws.com")
});

existingImageByName.GrantRead(role);
existingImageByArn.Grant(role, "imagebuilder:GetImage", "imagebuilder:ListImagePackages");
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
// Import by name
existingImageByName := imagebuilder.Image_FromImageName(this, jsii.String("ExistingImageByName"), jsii.String("my-existing-image"))

// Import by ARN
existingImageByArn := imagebuilder.Image_FromImageArn(this, jsii.String("ExistingImageByArn"), jsii.String("arn:aws:imagebuilder:us-east-1:123456789012:image/imported-image/1.0.0"))

// Import by attributes
existingImageByAttributes := imagebuilder.Image_FromImageAttributes(this, jsii.String("ExistingImageByAttributes"), &ImageAttributes{
	ImageName: jsii.String("shared-base-image"),
	ImageVersion: jsii.String("2024.11.25"),
})

// Grant permissions to imported images
role := iam.NewRole(this, jsii.String("ImageAccessRole"), &RoleProps{
	AssumedBy: iam.NewServicePrincipal(jsii.String("lambda.amazonaws.com")),
})

existingImageByName.GrantRead(role)
existingImageByArn.Grant(role, jsii.String("imagebuilder:GetImage"), jsii.String("imagebuilder:ListImagePackages"))
```

## Properties

- `imageArn`: string — The ARN of the image.

  **Default:** derived from the imageName

- `imageName`: string — The name of the image.

  **Default:** derived from the imageArn

- `imageVersion`: string — The version of the image.

  **Default:** the latest version of the image, x.x.x
