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

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:15.179Z") @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 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();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A fluent builder for CfnInclude.

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CfnInclude(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    CfnInclude(software.amazon.jsii.JsiiObjectRef objRef)
     
     
    CfnInclude(software.constructs.Construct scope, String id, CfnIncludeProps props)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    getCondition(String conditionName)
    Returns the CfnCondition object from the 'Conditions' section of the CloudFormation template with the given name.
    getHook(String hookLogicalId)
    Returns the CfnHook object from the 'Hooks' section of the included CloudFormation template with the given logical ID.
    getMapping(String mappingName)
    Returns the CfnMapping object from the 'Mappings' section of the included template.
    Returns a loaded NestedStack with name logicalId.
    getOutput(String logicalId)
    Returns the CfnOutput object from the 'Outputs' section of the included template.
    getParameter(String parameterName)
    Returns the CfnParameter object from the 'Parameters' section of the included template.
    getResource(String logicalId)
    Returns the low-level CfnResource from the template with the given logical ID.
    getRule(String ruleName)
    Returns the CfnRule object from the 'Rules' section of the CloudFormation template with the given name.
    loadNestedStack(String logicalId, CfnIncludeProps nestedStackProps)
    Includes a template for a child stack inside of this parent template.

    Methods inherited from class software.amazon.awscdk.CfnElement

    getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId

    Methods inherited from class software.constructs.Construct

    getNode, isConstruct, toString

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • 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 CfnIncludeProps.loadNestedStacks property, or through the loadNestedStack 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 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 returns for this logical ID