Skip to content
v2.273.0

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.

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"']
            }
          }
        ]
      }
    ]
  })
});

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) S3ComponentDatastatic#
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) ComponentDatastatic#
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) ComponentDatastatic#
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{}) ComponentDatastatic#
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) S3ComponentDatastatic#
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