Skip to content
v2.274.0

CfnTransformer L1 construct ​

Creates or updates a log transformer for a single log group.

You use log transformers to transform log events into a different format, making them easier for you to process and analyze. You can also transform logs from different sources into standardized formats that contains relevant, source-specific information.

After you have created a transformer, CloudWatch Logs performs the transformations at the time of log ingestion. You can then refer to the transformed versions of the logs during operations such as querying with CloudWatch Logs Insights or creating metric filters or subscription filers.

You can also use a transformer to copy metadata from metadata keys into the log events themselves. This metadata can include log group name, log stream name, account ID and Region.

A transformer for a log group is a series of processors, where each processor applies one type of transformation to the log events ingested into this log group. The processors work one after another, in the order that you list them, like a pipeline. For more information about the available processors to use in a transformer, see Processors that you can use .

Having log events in standardized format enables visibility across your applications for your log analysis, reporting, and alarming needs. CloudWatch Logs provides transformation for common log types with out-of-the-box transformation templates for major AWS log sources such as VPC flow logs, Lambda, and Amazon RDS. You can use pre-built transformation templates or create custom transformation policies.

You can create transformers only for the log groups in the Standard log class.

You can also set up a transformer at the account level. For more information, see PutAccountPolicy . If there is both a log-group level transformer created with PutTransformer and an account-level transformer that could apply to the same log group, the log group uses only the log-group level transformer. It ignores the account-level transformer.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_logs as logs } from 'aws-cdk-lib';
const cfnTransformer = new logs.CfnTransformer(this, 'MyCfnTransformer', {
  logGroupIdentifier: 'logGroupIdentifier',
  transformerConfig: [{
    addKeys: {
      entries: [{
        key: 'key',
        value: 'value',

        // the properties below are optional
        overwriteIfExists: false,
      }],
    },
    copyValue: {
      entries: [{
        source: 'source',
        target: 'target',

        // the properties below are optional
        overwriteIfExists: false,
      }],
    },
    csv: {
      columns: ['columns'],
      delimiter: 'delimiter',
      quoteCharacter: 'quoteCharacter',
      source: 'source',
    },
    dateTimeConverter: {
      matchPatterns: ['matchPatterns'],
      source: 'source',
      target: 'target',

      // the properties below are optional
      locale: 'locale',
      sourceTimezone: 'sourceTimezone',
      targetFormat: 'targetFormat',
      targetTimezone: 'targetTimezone',
    },
    deleteKeys: {
      withKeys: ['withKeys'],
    },
    grok: {
      match: 'match',

      // the properties below are optional
      source: 'source',
    },
    listToMap: {
      key: 'key',
      source: 'source',

      // the properties below are optional
      flatten: false,
      flattenedElement: 'flattenedElement',
      target: 'target',
      valueKey: 'valueKey',
    },
    lowerCaseString: {
      withKeys: ['withKeys'],
    },
    moveKeys: {
      entries: [{
        source: 'source',
        target: 'target',

        // the properties below are optional
        overwriteIfExists: false,
      }],
    },
    parseCloudfront: {
      source: 'source',
    },
    parseJson: {
      destination: 'destination',
      source: 'source',
    },
    parseKeyValue: {
      destination: 'destination',
      fieldDelimiter: 'fieldDelimiter',
      keyPrefix: 'keyPrefix',
      keyValueDelimiter: 'keyValueDelimiter',
      nonMatchValue: 'nonMatchValue',
      overwriteIfExists: false,
      source: 'source',
    },
    parsePostgres: {
      source: 'source',
    },
    parseRoute53: {
      source: 'source',
    },
    parseToOcsf: {
      eventSource: 'eventSource',
      ocsfVersion: 'ocsfVersion',

      // the properties below are optional
      mappingVersion: 'mappingVersion',
      source: 'source',
    },
    parseVpc: {
      source: 'source',
    },
    parseWaf: {
      source: 'source',
    },
    renameKeys: {
      entries: [{
        key: 'key',
        renameTo: 'renameTo',

        // the properties below are optional
        overwriteIfExists: false,
      }],
    },
    splitString: {
      entries: [{
        delimiter: 'delimiter',
        source: 'source',
      }],
    },
    substituteString: {
      entries: [{
        from: 'from',
        source: 'source',
        to: 'to',
      }],
    },
    trimString: {
      withKeys: ['withKeys'],
    },
    typeConverter: {
      entries: [{
        key: 'key',
        type: 'type',
      }],
    },
    upperCaseString: {
      withKeys: ['withKeys'],
    },
  }],
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_logs as logs

cfn_transformer = logs.CfnTransformer(self, "MyCfnTransformer",
    log_group_identifier="logGroupIdentifier",
    transformer_config=[logs.CfnTransformer.ProcessorProperty(
        add_keys=logs.CfnTransformer.AddKeysProperty(
            entries=[logs.CfnTransformer.AddKeyEntryProperty(
                key="key",
                value="value",

                # the properties below are optional
                overwrite_if_exists=False
            )]
        ),
        copy_value=logs.CfnTransformer.CopyValueProperty(
            entries=[logs.CfnTransformer.CopyValueEntryProperty(
                source="source",
                target="target",

                # the properties below are optional
                overwrite_if_exists=False
            )]
        ),
        csv=logs.CfnTransformer.CsvProperty(
            columns=["columns"],
            delimiter="delimiter",
            quote_character="quoteCharacter",
            source="source"
        ),
        date_time_converter=logs.CfnTransformer.DateTimeConverterProperty(
            match_patterns=["matchPatterns"],
            source="source",
            target="target",

            # the properties below are optional
            locale="locale",
            source_timezone="sourceTimezone",
            target_format="targetFormat",
            target_timezone="targetTimezone"
        ),
        delete_keys=logs.CfnTransformer.DeleteKeysProperty(
            with_keys=["withKeys"]
        ),
        grok=logs.CfnTransformer.GrokProperty(
            match="match",

            # the properties below are optional
            source="source"
        ),
        list_to_map=logs.CfnTransformer.ListToMapProperty(
            key="key",
            source="source",

            # the properties below are optional
            flatten=False,
            flattened_element="flattenedElement",
            target="target",
            value_key="valueKey"
        ),
        lower_case_string=logs.CfnTransformer.LowerCaseStringProperty(
            with_keys=["withKeys"]
        ),
        move_keys=logs.CfnTransformer.MoveKeysProperty(
            entries=[logs.CfnTransformer.MoveKeyEntryProperty(
                source="source",
                target="target",

                # the properties below are optional
                overwrite_if_exists=False
            )]
        ),
        parse_cloudfront=logs.CfnTransformer.ParseCloudfrontProperty(
            source="source"
        ),
        parse_json=logs.CfnTransformer.ParseJSONProperty(
            destination="destination",
            source="source"
        ),
        parse_key_value=logs.CfnTransformer.ParseKeyValueProperty(
            destination="destination",
            field_delimiter="fieldDelimiter",
            key_prefix="keyPrefix",
            key_value_delimiter="keyValueDelimiter",
            non_match_value="nonMatchValue",
            overwrite_if_exists=False,
            source="source"
        ),
        parse_postgres=logs.CfnTransformer.ParsePostgresProperty(
            source="source"
        ),
        parse_route53=logs.CfnTransformer.ParseRoute53Property(
            source="source"
        ),
        parse_to_ocsf=logs.CfnTransformer.ParseToOCSFProperty(
            event_source="eventSource",
            ocsf_version="ocsfVersion",

            # the properties below are optional
            mapping_version="mappingVersion",
            source="source"
        ),
        parse_vpc=logs.CfnTransformer.ParseVPCProperty(
            source="source"
        ),
        parse_waf=logs.CfnTransformer.ParseWAFProperty(
            source="source"
        ),
        rename_keys=logs.CfnTransformer.RenameKeysProperty(
            entries=[logs.CfnTransformer.RenameKeyEntryProperty(
                key="key",
                rename_to="renameTo",

                # the properties below are optional
                overwrite_if_exists=False
            )]
        ),
        split_string=logs.CfnTransformer.SplitStringProperty(
            entries=[logs.CfnTransformer.SplitStringEntryProperty(
                delimiter="delimiter",
                source="source"
            )]
        ),
        substitute_string=logs.CfnTransformer.SubstituteStringProperty(
            entries=[logs.CfnTransformer.SubstituteStringEntryProperty(
                from="from",
                source="source",
                to="to"
            )]
        ),
        trim_string=logs.CfnTransformer.TrimStringProperty(
            with_keys=["withKeys"]
        ),
        type_converter=logs.CfnTransformer.TypeConverterProperty(
            entries=[logs.CfnTransformer.TypeConverterEntryProperty(
                key="key",
                type="type"
            )]
        ),
        upper_case_string=logs.CfnTransformer.UpperCaseStringProperty(
            with_keys=["withKeys"]
        )
    )]
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.logs.*;

CfnTransformer cfnTransformer = CfnTransformer.Builder.create(this, "MyCfnTransformer")
        .logGroupIdentifier("logGroupIdentifier")
        .transformerConfig(List.of(ProcessorProperty.builder()
                .addKeys(AddKeysProperty.builder()
                        .entries(List.of(AddKeyEntryProperty.builder()
                                .key("key")
                                .value("value")

                                // the properties below are optional
                                .overwriteIfExists(false)
                                .build()))
                        .build())
                .copyValue(CopyValueProperty.builder()
                        .entries(List.of(CopyValueEntryProperty.builder()
                                .source("source")
                                .target("target")

                                // the properties below are optional
                                .overwriteIfExists(false)
                                .build()))
                        .build())
                .csv(CsvProperty.builder()
                        .columns(List.of("columns"))
                        .delimiter("delimiter")
                        .quoteCharacter("quoteCharacter")
                        .source("source")
                        .build())
                .dateTimeConverter(DateTimeConverterProperty.builder()
                        .matchPatterns(List.of("matchPatterns"))
                        .source("source")
                        .target("target")

                        // the properties below are optional
                        .locale("locale")
                        .sourceTimezone("sourceTimezone")
                        .targetFormat("targetFormat")
                        .targetTimezone("targetTimezone")
                        .build())
                .deleteKeys(DeleteKeysProperty.builder()
                        .withKeys(List.of("withKeys"))
                        .build())
                .grok(GrokProperty.builder()
                        .match("match")

                        // the properties below are optional
                        .source("source")
                        .build())
                .listToMap(ListToMapProperty.builder()
                        .key("key")
                        .source("source")

                        // the properties below are optional
                        .flatten(false)
                        .flattenedElement("flattenedElement")
                        .target("target")
                        .valueKey("valueKey")
                        .build())
                .lowerCaseString(LowerCaseStringProperty.builder()
                        .withKeys(List.of("withKeys"))
                        .build())
                .moveKeys(MoveKeysProperty.builder()
                        .entries(List.of(MoveKeyEntryProperty.builder()
                                .source("source")
                                .target("target")

                                // the properties below are optional
                                .overwriteIfExists(false)
                                .build()))
                        .build())
                .parseCloudfront(ParseCloudfrontProperty.builder()
                        .source("source")
                        .build())
                .parseJson(ParseJSONProperty.builder()
                        .destination("destination")
                        .source("source")
                        .build())
                .parseKeyValue(ParseKeyValueProperty.builder()
                        .destination("destination")
                        .fieldDelimiter("fieldDelimiter")
                        .keyPrefix("keyPrefix")
                        .keyValueDelimiter("keyValueDelimiter")
                        .nonMatchValue("nonMatchValue")
                        .overwriteIfExists(false)
                        .source("source")
                        .build())
                .parsePostgres(ParsePostgresProperty.builder()
                        .source("source")
                        .build())
                .parseRoute53(ParseRoute53Property.builder()
                        .source("source")
                        .build())
                .parseToOcsf(ParseToOCSFProperty.builder()
                        .eventSource("eventSource")
                        .ocsfVersion("ocsfVersion")

                        // the properties below are optional
                        .mappingVersion("mappingVersion")
                        .source("source")
                        .build())
                .parseVpc(ParseVPCProperty.builder()
                        .source("source")
                        .build())
                .parseWaf(ParseWAFProperty.builder()
                        .source("source")
                        .build())
                .renameKeys(RenameKeysProperty.builder()
                        .entries(List.of(RenameKeyEntryProperty.builder()
                                .key("key")
                                .renameTo("renameTo")

                                // the properties below are optional
                                .overwriteIfExists(false)
                                .build()))
                        .build())
                .splitString(SplitStringProperty.builder()
                        .entries(List.of(SplitStringEntryProperty.builder()
                                .delimiter("delimiter")
                                .source("source")
                                .build()))
                        .build())
                .substituteString(SubstituteStringProperty.builder()
                        .entries(List.of(SubstituteStringEntryProperty.builder()
                                .from("from")
                                .source("source")
                                .to("to")
                                .build()))
                        .build())
                .trimString(TrimStringProperty.builder()
                        .withKeys(List.of("withKeys"))
                        .build())
                .typeConverter(TypeConverterProperty.builder()
                        .entries(List.of(TypeConverterEntryProperty.builder()
                                .key("key")
                                .type("type")
                                .build()))
                        .build())
                .upperCaseString(UpperCaseStringProperty.builder()
                        .withKeys(List.of("withKeys"))
                        .build())
                .build()))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Logs;

var cfnTransformer = new CfnTransformer(this, "MyCfnTransformer", new CfnTransformerProps {
    LogGroupIdentifier = "logGroupIdentifier",
    TransformerConfig = new [] { new ProcessorProperty {
        AddKeys = new AddKeysProperty {
            Entries = new [] { new AddKeyEntryProperty {
                Key = "key",
                Value = "value",

                // the properties below are optional
                OverwriteIfExists = false
            } }
        },
        CopyValue = new CopyValueProperty {
            Entries = new [] { new CopyValueEntryProperty {
                Source = "source",
                Target = "target",

                // the properties below are optional
                OverwriteIfExists = false
            } }
        },
        Csv = new CsvProperty {
            Columns = new [] { "columns" },
            Delimiter = "delimiter",
            QuoteCharacter = "quoteCharacter",
            Source = "source"
        },
        DateTimeConverter = new DateTimeConverterProperty {
            MatchPatterns = new [] { "matchPatterns" },
            Source = "source",
            Target = "target",

            // the properties below are optional
            Locale = "locale",
            SourceTimezone = "sourceTimezone",
            TargetFormat = "targetFormat",
            TargetTimezone = "targetTimezone"
        },
        DeleteKeys = new DeleteKeysProperty {
            WithKeys = new [] { "withKeys" }
        },
        Grok = new GrokProperty {
            Match = "match",

            // the properties below are optional
            Source = "source"
        },
        ListToMap = new ListToMapProperty {
            Key = "key",
            Source = "source",

            // the properties below are optional
            Flatten = false,
            FlattenedElement = "flattenedElement",
            Target = "target",
            ValueKey = "valueKey"
        },
        LowerCaseString = new LowerCaseStringProperty {
            WithKeys = new [] { "withKeys" }
        },
        MoveKeys = new MoveKeysProperty {
            Entries = new [] { new MoveKeyEntryProperty {
                Source = "source",
                Target = "target",

                // the properties below are optional
                OverwriteIfExists = false
            } }
        },
        ParseCloudfront = new ParseCloudfrontProperty {
            Source = "source"
        },
        ParseJson = new ParseJSONProperty {
            Destination = "destination",
            Source = "source"
        },
        ParseKeyValue = new ParseKeyValueProperty {
            Destination = "destination",
            FieldDelimiter = "fieldDelimiter",
            KeyPrefix = "keyPrefix",
            KeyValueDelimiter = "keyValueDelimiter",
            NonMatchValue = "nonMatchValue",
            OverwriteIfExists = false,
            Source = "source"
        },
        ParsePostgres = new ParsePostgresProperty {
            Source = "source"
        },
        ParseRoute53 = new ParseRoute53Property {
            Source = "source"
        },
        ParseToOcsf = new ParseToOCSFProperty {
            EventSource = "eventSource",
            OcsfVersion = "ocsfVersion",

            // the properties below are optional
            MappingVersion = "mappingVersion",
            Source = "source"
        },
        ParseVpc = new ParseVPCProperty {
            Source = "source"
        },
        ParseWaf = new ParseWAFProperty {
            Source = "source"
        },
        RenameKeys = new RenameKeysProperty {
            Entries = new [] { new RenameKeyEntryProperty {
                Key = "key",
                RenameTo = "renameTo",

                // the properties below are optional
                OverwriteIfExists = false
            } }
        },
        SplitString = new SplitStringProperty {
            Entries = new [] { new SplitStringEntryProperty {
                Delimiter = "delimiter",
                Source = "source"
            } }
        },
        SubstituteString = new SubstituteStringProperty {
            Entries = new [] { new SubstituteStringEntryProperty {
                From = "from",
                Source = "source",
                To = "to"
            } }
        },
        TrimString = new TrimStringProperty {
            WithKeys = new [] { "withKeys" }
        },
        TypeConverter = new TypeConverterProperty {
            Entries = new [] { new TypeConverterEntryProperty {
                Key = "key",
                Type = "type"
            } }
        },
        UpperCaseString = new UpperCaseStringProperty {
            WithKeys = new [] { "withKeys" }
        }
    } }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnTransformer := awscdk.Aws_logs.NewCfnTransformer(this, jsii.String("MyCfnTransformer"), &CfnTransformerProps{
	LogGroupIdentifier: jsii.String("logGroupIdentifier"),
	TransformerConfig: []interface{}{
		&ProcessorProperty{
			AddKeys: &AddKeysProperty{
				Entries: []interface{}{
					&AddKeyEntryProperty{
						Key: jsii.String("key"),
						Value: jsii.String("value"),

						// the properties below are optional
						OverwriteIfExists: jsii.Boolean(false),
					},
				},
			},
			CopyValue: &CopyValueProperty{
				Entries: []interface{}{
					&CopyValueEntryProperty{
						Source: jsii.String("source"),
						Target: jsii.String("target"),

						// the properties below are optional
						OverwriteIfExists: jsii.Boolean(false),
					},
				},
			},
			Csv: &CsvProperty{
				Columns: []*string{
					jsii.String("columns"),
				},
				Delimiter: jsii.String("delimiter"),
				QuoteCharacter: jsii.String("quoteCharacter"),
				Source: jsii.String("source"),
			},
			DateTimeConverter: &DateTimeConverterProperty{
				MatchPatterns: []*string{
					jsii.String("matchPatterns"),
				},
				Source: jsii.String("source"),
				Target: jsii.String("target"),

				// the properties below are optional
				Locale: jsii.String("locale"),
				SourceTimezone: jsii.String("sourceTimezone"),
				TargetFormat: jsii.String("targetFormat"),
				TargetTimezone: jsii.String("targetTimezone"),
			},
			DeleteKeys: &DeleteKeysProperty{
				WithKeys: []*string{
					jsii.String("withKeys"),
				},
			},
			Grok: &GrokProperty{
				Match: jsii.String("match"),

				// the properties below are optional
				Source: jsii.String("source"),
			},
			ListToMap: &ListToMapProperty{
				Key: jsii.String("key"),
				Source: jsii.String("source"),

				// the properties below are optional
				Flatten: jsii.Boolean(false),
				FlattenedElement: jsii.String("flattenedElement"),
				Target: jsii.String("target"),
				ValueKey: jsii.String("valueKey"),
			},
			LowerCaseString: &LowerCaseStringProperty{
				WithKeys: []*string{
					jsii.String("withKeys"),
				},
			},
			MoveKeys: &MoveKeysProperty{
				Entries: []interface{}{
					&MoveKeyEntryProperty{
						Source: jsii.String("source"),
						Target: jsii.String("target"),

						// the properties below are optional
						OverwriteIfExists: jsii.Boolean(false),
					},
				},
			},
			ParseCloudfront: &ParseCloudfrontProperty{
				Source: jsii.String("source"),
			},
			ParseJson: &ParseJSONProperty{
				Destination: jsii.String("destination"),
				Source: jsii.String("source"),
			},
			ParseKeyValue: &ParseKeyValueProperty{
				Destination: jsii.String("destination"),
				FieldDelimiter: jsii.String("fieldDelimiter"),
				KeyPrefix: jsii.String("keyPrefix"),
				KeyValueDelimiter: jsii.String("keyValueDelimiter"),
				NonMatchValue: jsii.String("nonMatchValue"),
				OverwriteIfExists: jsii.Boolean(false),
				Source: jsii.String("source"),
			},
			ParsePostgres: &ParsePostgresProperty{
				Source: jsii.String("source"),
			},
			ParseRoute53: &ParseRoute53Property{
				Source: jsii.String("source"),
			},
			ParseToOcsf: &ParseToOCSFProperty{
				EventSource: jsii.String("eventSource"),
				OcsfVersion: jsii.String("ocsfVersion"),

				// the properties below are optional
				MappingVersion: jsii.String("mappingVersion"),
				Source: jsii.String("source"),
			},
			ParseVpc: &ParseVPCProperty{
				Source: jsii.String("source"),
			},
			ParseWaf: &ParseWAFProperty{
				Source: jsii.String("source"),
			},
			RenameKeys: &RenameKeysProperty{
				Entries: []interface{}{
					&RenameKeyEntryProperty{
						Key: jsii.String("key"),
						RenameTo: jsii.String("renameTo"),

						// the properties below are optional
						OverwriteIfExists: jsii.Boolean(false),
					},
				},
			},
			SplitString: &SplitStringProperty{
				Entries: []interface{}{
					&SplitStringEntryProperty{
						Delimiter: jsii.String("delimiter"),
						Source: jsii.String("source"),
					},
				},
			},
			SubstituteString: &SubstituteStringProperty{
				Entries: []interface{}{
					&SubstituteStringEntryProperty{
						From: jsii.String("from"),
						Source: jsii.String("source"),
						To: jsii.String("to"),
					},
				},
			},
			TrimString: &TrimStringProperty{
				WithKeys: []*string{
					jsii.String("withKeys"),
				},
			},
			TypeConverter: &TypeConverterProperty{
				Entries: []interface{}{
					&TypeConverterEntryProperty{
						Key: jsii.String("key"),
						Type: jsii.String("type"),
					},
				},
			},
			UpperCaseString: &UpperCaseStringProperty{
				WithKeys: []*string{
					jsii.String("withKeys"),
				},
			},
		},
	},
})

Initializer ​

ts
new CfnTransformer(scope: Construct, id: string, props: CfnTransformerProps)
python
CfnTransformer(scope: Construct, id: str, props: CfnTransformerProps)
java
new CfnTransformer(Construct scope, String id, CfnTransformerProps props)
csharp
new CfnTransformer(Construct scope, string id, CfnTransformerProps props)
go
NewCfnTransformer(Scope Construct, Id *string, Props CfnTransformerProps)

Construct Props ​

logGroupIdentifierstringlog_group_identifierstrlogGroupIdentifierStringLogGroupIdentifierstringLogGroupIdentifier*stringrequired#
Specify either the name or ARN of the log group to create the transformer for.
transformerConfigIResolvable | IResolvable | CfnTransformer.ProcessorProperty[]transformer_configtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ProcessorProperty]]]transformerConfigIResolvableTransformerConfigIResolvableTransformerConfiginterface{}required#
This structure is an array that contains the configuration of this log transformer.

A log transformer is an array of processors, where each processor applies one type of transformation to the log events that are ingested.

Properties ​

CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringstatic#
The CloudFormation resource type name for this resource class.
Options for this resource, such as condition, update policy etc.
cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*string#
AWS resource type.
creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*string#
logGroupIdentifierstringlog_group_identifierstrlogGroupIdentifierStringLogGroupIdentifierstringLogGroupIdentifier*string#
Specify either the name or ARN of the log group to create the transformer for.
logicalIdstringlogical_idstrlogicalIdStringLogicalIdstringLogicalId*string#
The logical ID for this CloudFormation stack element.

The logical ID of the element is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
refstringrefstrrefStringRefstringRef*string#
Return a string that will be resolved to a CloudFormation `{ Ref }` for this element.

If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).

stackStackstackStackstackStackStackStackStackStack#
The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

transformerConfigIResolvable | IResolvable | CfnTransformer.ProcessorProperty[]transformer_configtyping.Union[IResolvable, typing.List[typing.Union[IResolvable, ProcessorProperty]]]transformerConfigIResolvableTransformerConfigIResolvableTransformerConfiginterface{}#
This structure is an array that contains the configuration of this log transformer.
transformerRefTransformerReferencetransformer_refTransformerReferencetransformerRefTransformerReferenceTransformerRefTransformerReferenceTransformerRefTransformerReference#
A reference to a Transformer resource.

Methods ​

addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#
Syntactic sugar for `addOverride(path, undefined)`.
1 parameter

Parameters

  • pathpathpathpathPath — The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#
Use `addResourceDependency` instead.

This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.

addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#
Use `addResourceDependency` instead.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.

addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#
Add a value to the CloudFormation Resource Metadata.
addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#
Adds an override to the synthesized CloudFormation resource.
notes · 2 parameters

To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).

If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.

To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.

For example,

typescript
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');

would add the overrides

json
"Properties": {
  "GlobalSecondaryIndexes": [
    {
      "Projection": {
        "NonKeyAttributes": [ "myattribute" ]
        ...
      }
      ...
    },
    {
      "ProjectionType": "INCLUDE"
      ...
    },
  ]
  ...
}

The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.

Parameters

  • pathpathpathpathPath — - The path of the property, you can use dot notation to override values in complex types.
  • valuevaluevaluevalueValue — - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#
Adds an override that deletes the value of a property from the resource definition.
1 parameter

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#
Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

2 parameters

Parameters

  • propertyPathproperty_pathpropertyPathpropertyPathPropertyPath — The path of the property.
  • valuevaluevaluevalueValue — The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
notes

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.

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)#
Sets the cross-stack reference strength for this resource.

When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.

1 parameter

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#
Sets the deletion policy of the resource based on the removal policy specified.
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). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:

cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#
getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#
Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

1 parameter

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#
Retrieve a value value from the CloudFormation Resource Metadata.
inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#
Examines the CloudFormation resource and discloses attributes.
1 parameter

Parameters

  • inspectorinspectorinspectorinspectorInspector — tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#
Returns `true` if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

returns

Returns: The construct as a stack element or undefined if it is not a stack element.

isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#
Check whether the given object is a CfnResource.
isCfnTransformer(x: any): boolean@staticmethod def is_cfn_transformer(x: Any) -> boolpublic static Boolean isCfnTransformer(Object x)public static bool IsCfnTransformer(object x)func IsCfnTransformer(X interface{}) *boolstatic#
Checks whether the given object is a CfnTransformer.
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.

obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#
Retrieves an array of resources and stacks this resource depends on.

For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.

overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#
Overrides the auto-generated logical ID with a specific ID.
1 parameter

Parameters

  • newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId — The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#
Use `removeResourceDependency` instead

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#
Indicates that this resource no longer depends on another resource.

This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.

replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#
Replaces one dependency with another.
2 parameters

Parameters

  • targettargettargettargetTarget — The dependency to replace.
  • newTargetnew_targetnewTargetnewTargetNewTarget — The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
returns

Returns: a string representation of this resource

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.