java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.CfnElement
software.amazon.awscdk.cloudformation.include.CfnInclude
All Implemented Interfaces:
IConstruct, IDependable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:49.951Z") @Stability(Stable) public class CfnInclude extends CfnElement
Construct to import an existing CloudFormation template file into a CDK application.

All resources defined in the template file can be retrieved by calling the getResource(java.lang.String) method. Any modifications made on the returned resource objects will be reflected in the resulting CDK template.

Example:

 CfnInclude cfnTemplate = CfnInclude.Builder.create(this, "Template")
         .templateFile("my-template.json")
         .build();
 
  • Constructor Details

    • CfnInclude

      protected CfnInclude(software.amazon.jsii.JsiiObjectRef objRef)
    • CfnInclude

      protected CfnInclude(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CfnInclude

      @Stability(Stable) public CfnInclude(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnIncludeProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • getCondition

      @Stability(Stable) @NotNull public CfnCondition getCondition(@NotNull String conditionName)
      Returns the CfnCondition object from the 'Conditions' section of the CloudFormation template with the given name.

      Any modifications performed on that object will be reflected in the resulting CDK template.

      If a Condition with the given name is not present in the template, throws an exception.

      Parameters:
      conditionName - the name of the Condition in the CloudFormation template file. This parameter is required.
    • getHook

      @Stability(Stable) @NotNull public CfnHook getHook(@NotNull String hookLogicalId)
      Returns the CfnHook object from the 'Hooks' section of the included CloudFormation template with the given logical ID.

      Any modifications performed on the returned object will be reflected in the resulting CDK template.

      If a Hook with the given logical ID is not present in the template, an exception will be thrown.

      Parameters:
      hookLogicalId - the logical ID of the Hook in the included CloudFormation template's 'Hooks' section. This parameter is required.
    • getMapping

      @Stability(Stable) @NotNull public CfnMapping getMapping(@NotNull String mappingName)
      Returns the CfnMapping object from the 'Mappings' section of the included template.

      Any modifications performed on that object will be reflected in the resulting CDK template.

      If a Mapping with the given name is not present in the template, an exception will be thrown.

      Parameters:
      mappingName - the name of the Mapping in the template to retrieve. This parameter is required.
    • getNestedStack

      @Stability(Stable) @NotNull public IncludedNestedStack getNestedStack(@NotNull String logicalId)
      Returns a loaded NestedStack with name logicalId.

      For a nested stack to be returned by this method, it must be specified either in the

      invalid @link
      CfnIncludeProps.loadNestedStacks
      property, or through the loadNestedStack(java.lang.String,software.amazon.awscdk.cloudformation.include.CfnIncludeProps) method.

      Parameters:
      logicalId - the ID of the stack to retrieve, as it appears in the template. This parameter is required.
    • getOutput

      @Stability(Stable) @NotNull public CfnOutput getOutput(@NotNull String logicalId)
      Returns the CfnOutput object from the 'Outputs' section of the included template.

      Any modifications performed on that object will be reflected in the resulting CDK template.

      If an Output with the given name is not present in the template, throws an exception.

      Parameters:
      logicalId - the name of the output to retrieve. This parameter is required.
    • getParameter

      @Stability(Stable) @NotNull public CfnParameter getParameter(@NotNull String parameterName)
      Returns the CfnParameter object from the 'Parameters' section of the included template.

      Any modifications performed on that object will be reflected in the resulting CDK template.

      If a Parameter with the given name is not present in the template, throws an exception.

      Parameters:
      parameterName - the name of the parameter to retrieve. This parameter is required.
    • getResource

      @Stability(Stable) @NotNull public CfnResource getResource(@NotNull String logicalId)
      Returns the low-level CfnResource from the template with the given logical ID.

      Any modifications performed on that resource will be reflected in the resulting CDK template.

      The returned object will be of the proper underlying class; you can always cast it to the correct type in your code:

        // assume the template contains an AWS::S3::Bucket with logical ID 'Bucket'
        const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
        // cfnBucket is of type s3.CfnBucket
       

      If the template does not contain a resource with the given logical ID, an exception will be thrown.

      Parameters:
      logicalId - the logical ID of the resource in the CloudFormation template file. This parameter is required.
    • getRule

      @Stability(Stable) @NotNull public CfnRule getRule(@NotNull String ruleName)
      Returns the CfnRule object from the 'Rules' section of the CloudFormation template with the given name.

      Any modifications performed on that object will be reflected in the resulting CDK template.

      If a Rule with the given name is not present in the template, an exception will be thrown.

      Parameters:
      ruleName - the name of the Rule in the CloudFormation template. This parameter is required.
    • loadNestedStack

      @Stability(Stable) @NotNull public IncludedNestedStack loadNestedStack(@NotNull String logicalId, @NotNull CfnIncludeProps nestedStackProps)
      Includes a template for a child stack inside of this parent template.

      A child with this logical ID must exist in the template, and be of type AWS::CloudFormation::Stack. This is equivalent to specifying the value in the

      invalid @link
      CfnIncludeProps.loadNestedStacks
      property on object construction.

      Parameters:
      logicalId - the ID of the stack to retrieve, as it appears in the template. This parameter is required.
      nestedStackProps - the properties of the included child Stack. This parameter is required.
      Returns:
      the same IncludedNestedStack object that getNestedStack(java.lang.String) returns for this logical ID