Experimental
@aws-cdk/aws-imagebuilder-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
ComponentData Class
Helper class for referencing and uploading component data.
| Stability | Experimental |
|---|---|
| Source | lib/component.ts |
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 ComponentData()
python
ComponentData()
java
new ComponentData()
csharp
new ComponentData()
go
NewComponentData()
Methods
fromAsset(scope: Construct, id: string, path: string, options?: AssetOptions): S3ComponentData@staticmethod def from_asset(scope: Construct, id: str, path: str, options: typing.Optional[AssetOptions] = None) -> S3ComponentDatapublic static S3ComponentData fromAsset(Construct scope, String id, String path, AssetOptions options)public static S3ComponentData FromAsset(Construct scope, string id, string path, AssetOptions? options = null)func FromAsset(Scope Construct, Id *string, Path *string, Options AssetOptions) S3ComponentData static #Uploads component data from a local file to S3 to use as the component data.
4 parameters
Parameters
scopescopescopescopeScope— The construct scope.ididididId— Identifier of the construct.pathpathpathpathPath— The local path to the component data file.optionsoptionsoptionsoptionsOptions— S3 asset upload options.
fromComponentDocumentJsonObject(data: ComponentDocument): ComponentData // chainable@staticmethod def from_component_document_json_object(data: ComponentDocument) -> ComponentDatapublic static ComponentData fromComponentDocumentJsonObject(ComponentDocument data)public static ComponentData FromComponentDocumentJsonObject(ComponentDocument data)func FromComponentDocumentJsonObject(Data ComponentDocument) ComponentData static #Uses an inline JSON object as the component data, using the ComponentDocument interface.
1 parameter
Parameters
datadatadatadataData— An inline JSON object representing the component data.
fromInline(data: string): ComponentData // chainable@staticmethod def from_inline(data: str) -> ComponentDatapublic static ComponentData fromInline(String data)public static ComponentData FromInline(string data)func FromInline(Data *string) ComponentData static #Uses an inline JSON/YAML string as the component data.
1 parameter
Parameters
datadatadatadataData— An inline JSON/YAML string representing the component data.
fromJsonObject(data: { [key: string]: any }): ComponentData // chainable@staticmethod def from_json_object(data: typing.Mapping[str, Any]) -> ComponentDatapublic static ComponentData fromJsonObject(Map<String, Object> data)public static ComponentData FromJsonObject(IDictionary<string, object> data)func FromJsonObject(Data *map[string]interface{}) ComponentData static #Uses an inline JSON object as the component data.
1 parameter
Parameters
datadatadatadataData— An inline JSON object representing the component data.
fromS3(bucket: IBucket, key: string): S3ComponentData@staticmethod def from_s3(bucket: IBucket, key: str) -> S3ComponentDatapublic static S3ComponentData fromS3(IBucket bucket, String key)public static S3ComponentData FromS3(IBucket bucket, string key)func FromS3(Bucket IBucket, Key *string) S3ComponentData static #References component data from a pre-existing S3 object.
2 parameters
Parameters
bucketbucketbucketbucketBucket— The S3 bucket where the component data is stored.keykeykeykeyKey— The S3 key of the component data file.
render(): ComponentDataConfigdef render(self, ) -> ComponentDataConfigpublic ComponentDataConfig render()public ComponentDataConfig Render()func Render() ComponentDataConfig #The rendered component data value, for use in CloudFormation.
- For inline components, data is the component text
- For S3-backed components, uri is the S3 URL