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
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"']
}
}
]
}
]
})
});
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\""]
}
}
]
}
]
})
)
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();
// 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\"" }
}
} } }
} } }
})
});
// 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
new Component(scope: Construct, id: string, props: ComponentProps)
Component(scope: Construct, id: str, props: ComponentProps)
new Component(Construct scope, String id, ComponentProps props)
new Component(Construct scope, string id, ComponentProps props)
NewComponent(Scope Construct, Id *string, Props ComponentProps)
Construct Props
changeDescriptionstringchange_descriptionstrchangeDescriptionStringChangeDescriptionstringChangeDescription*string= None#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#componentVersionstringcomponent_versionstrcomponentVersionStringComponentVersionstringComponentVersion*string= 1.0.0#default
Default: an Image Builder owned key will be used to encrypt the component.
supportedOsVersionsOSVersion[]supported_os_versionstyping.List[OSVersion]supportedOsVersionsList<OSVersion>SupportedOsVersionsOSVersion[]SupportedOsVersions*[]OSVersion= None#tags{ [key: string]: string }tagstyping.Mapping[str, str]tagsMap<String, String>TagsIDictionary<string, string>Tags*map[string]*string= None#Properties
componentNamestringcomponent_namestrcomponentNameStringComponentNamestringComponentName*stringrequired#componentTypestringcomponent_typestrcomponentTypeStringComponentTypestringComponentType*stringrequired#componentVersionstringcomponent_versionstrcomponentVersionStringComponentVersionstringComponentVersion*stringrequired#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.
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).
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#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#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#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#[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#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.
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.