Skip to content
v2.274.0

Experimental

@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

Component L2 construct ​

Represents an EC2 Image Builder Component.

Example ​

ts
const component = new imagebuilder.Component(this, 'EncryptedComponent', {
  platform: imagebuilder.Platform.LINUX,
  kmsKey: new kms.Key(this, 'ComponentKey'),
  data: imagebuilder.ComponentData.fromJsonObject({
    schemaVersion: imagebuilder.ComponentSchemaVersion.V1_0,
    phases: [
      {
        name: imagebuilder.ComponentPhaseName.BUILD,
        steps: [
          {
            name: 'secure-setup',
            action: imagebuilder.ComponentAction.EXECUTE_BASH,
            inputs: {
              commands: ['echo "This component data is encrypted with KMS"']
            }
          }
        ]
      }
    ]
  })
});
python
component = imagebuilder.Component(self, "EncryptedComponent",
    platform=imagebuilder.Platform.LINUX,
    kms_key=kms.Key(self, "ComponentKey"),
    data=imagebuilder.ComponentData.from_json_object({
        "schema_version": imagebuilder.ComponentSchemaVersion.V1_0,
        "phases": [{
            "name": imagebuilder.ComponentPhaseName.BUILD,
            "steps": [{
                "name": "secure-setup",
                "action": imagebuilder.ComponentAction.EXECUTE_BASH,
                "inputs": {
                    "commands": ["echo \"This component data is encrypted with KMS\""]
                }
            }
            ]
        }
        ]
    })
)
java
Component component = Component.Builder.create(this, "EncryptedComponent")
        .platform(Platform.LINUX)
        .kmsKey(new Key(this, "ComponentKey"))
        .data(ComponentData.fromJsonObject(Map.of(
                "schemaVersion", ComponentSchemaVersion.V1_0,
                "phases", List.of(Map.of(
                        "name", ComponentPhaseName.BUILD,
                        "steps", List.of(Map.of(
                                "name", "secure-setup",
                                "action", ComponentAction.EXECUTE_BASH,
                                "inputs", Map.of(
                                        "commands", List.of("echo \"This component data is encrypted with KMS\"")))))))))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.ImageBuilder.Alpha
var component = new Component(this, "EncryptedComponent", new ComponentProps {
    Platform = Platform.LINUX,
    KmsKey = new Key(this, "ComponentKey"),
    Data = ComponentData.FromJsonObject(new Dictionary<string, object> {
        { "schemaVersion", ComponentSchemaVersion.V1_0 },
        { "phases", new [] { new Dictionary<string, object> {
            { "name", ComponentPhaseName.BUILD },
            { "steps", new [] { new Struct {
                Name = "secure-setup",
                Action = ComponentAction.EXECUTE_BASH,
                Inputs = new Struct {
                    Commands = new [] { "echo \"This component data is encrypted with KMS\"" }
                }
            } } }
        } } }
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2
component := imagebuilder.NewComponent(this, jsii.String("EncryptedComponent"), &ComponentProps{
	Platform: imagebuilder.Platform_LINUX,
	KmsKey: kms.NewKey(this, jsii.String("ComponentKey")),
	Data: imagebuilder.ComponentData_FromJsonObject(map[string]interface{}{
		"schemaVersion": imagebuilder.ComponentSchemaVersion_V1_0,
		"phases": []interface{}{
			map[string]interface{}{
				"name": imagebuilder.ComponentPhaseName_BUILD,
				"steps": []map[string]interface{}{
					map[string]interface{}{
						"name": jsii.String("secure-setup"),
						"action": imagebuilder.ComponentAction_EXECUTE_BASH,
						"inputs": map[string][]*string{
							"commands": []*string{
								jsii.String("echo \"This component data is encrypted with KMS\""),
							},
						},
					},
				},
			},
		},
	}),
})

Initializer ​

ts
new Component(scope: Construct, id: string, props: ComponentProps)
python
Component(scope: Construct, id: str, props: ComponentProps)
java
new Component(Construct scope, String id, ComponentProps props)
csharp
new Component(Construct scope, string id, ComponentProps props)
go
NewComponent(Scope Construct, Id *string, Props ComponentProps)

Construct Props ​

changeDescriptionstringchange_descriptionstrchangeDescriptionStringChangeDescriptionstringChangeDescription*string= None#
The change description of the component.

Describes what change has been made in this version of the component, or what makes this version different from other versions.

componentNamestringcomponent_namestrcomponentNameStringComponentNamestringComponentName*string= a name is generated#
The name of the component.
componentVersionstringcomponent_versionstrcomponentVersionStringComponentVersionstringComponentVersion*string= 1.0.0#
The version of the component.
The component document content that defines the build, validation, or test steps to be executed during the image building process.
descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= None#
The description of the component.
kmsKeyIKeykms_keyIKeykmsKeyIKeyKmsKeyIKeyKmsKeyIKey= an Image Builder owned key will …#
The KMS key used to encrypt this component.
default

Default: an Image Builder owned key will be used to encrypt the component.

platformPlatformplatformPlatformplatformPlatformPlatformPlatformPlatformPlatformrequired#
The operating system platform of the component.
supportedOsVersionsOSVersion[]supported_os_versionstyping.List[OSVersion]supportedOsVersionsList<OSVersion>SupportedOsVersionsOSVersion[]SupportedOsVersions*[]OSVersion= None#
The operating system versions supported by the component.
tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#
The tags to apply to the component.

Properties ​

componentArnstringcomponent_arnstrcomponentArnStringComponentArnstringComponentArn*stringrequired#
The ARN of the component.
componentNamestringcomponent_namestrcomponentNameStringComponentNamestringComponentName*stringrequired#
The name of the component.
componentTypestringcomponent_typestrcomponentTypeStringComponentTypestringComponentType*stringrequired#
The type of the component.
componentVersionstringcomponent_versionstrcomponentVersionStringComponentVersionstringComponentVersion*stringrequired#
The version of the component.
encryptedbooleanencryptedboolencryptedBooleanEncryptedboolEncrypted*boolrequired#
Whether the component is encrypted.
The environment this resource belongs to.
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.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

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)#
Override the cross-stack reference strength for this resource.
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)#
Apply the given removal policy to this resource.
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).

fromComponentArn(scope: Construct, id: string, componentArn: string): IComponent@staticmethod def from_component_arn(scope: Construct, id: str, component_arn: str) -> IComponentpublic static IComponent fromComponentArn(Construct scope, String id, String componentArn)public static IComponent FromComponentArn(Construct scope, string id, string componentArn)func FromComponentArn(Scope Construct, Id *string, ComponentArn *string) IComponentstatic#
Import an existing component given its ARN.
fromComponentAttributes(scope: Construct, id: string, attrs: ComponentAttributes): IComponent@staticmethod def from_component_attributes(scope: Construct, id: str, attrs: ComponentAttributes) -> IComponentpublic static IComponent fromComponentAttributes(Construct scope, String id, ComponentAttributes attrs)public static IComponent FromComponentAttributes(Construct scope, string id, ComponentAttributes attrs)func FromComponentAttributes(Scope Construct, Id *string, Attrs ComponentAttributes) IComponentstatic#
Import an existing component by providing its attributes.

If the component name is provided as an attribute, it must be normalized by converting all alphabetical characters to lowercase, and replacing all spaces and underscores with hyphens.

fromComponentName(scope: Construct, id: string, componentName: string): IComponent@staticmethod def from_component_name(scope: Construct, id: str, component_name: str) -> IComponentpublic static IComponent fromComponentName(Construct scope, String id, String componentName)public static IComponent FromComponentName(Construct scope, string id, string componentName)func FromComponentName(Scope Construct, Id *string, ComponentName *string) IComponentstatic#
Import an existing component 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[]): 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#
Grant custom actions to the given grantee for the component [disable-awslint:no-grants].
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#
Grant read permissions to the given grantee for the component.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal.
isComponent(x: any): boolean@staticmethod def is_component(x: Any) -> boolpublic static Boolean isComponent(Object x)public static bool IsComponent(object x)func IsComponent(X interface{}) *boolstatic#
Return whether the given object is a Component.
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#
Checks if `x` is a construct.
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.

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#
Returns true if the construct was created by CDK, and false otherwise.
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#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func 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.