agent-claw: automated task changes

This commit is contained in:
daniel
2026-05-06 18:55:16 -05:00
parent 38905bb1e9
commit 732b00fb66
8494 changed files with 2018127 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
{
"targets": {
"java": {
"package": "software.amazon.awscdk.cloudformation.include"
},
"dotnet": {
"namespace": "Amazon.CDK.CloudFormation.Include"
},
"python": {
"module": "aws_cdk.cloudformation_include"
}
}
}

View File

@@ -0,0 +1,468 @@
# Include CloudFormation templates in the CDK
This module contains a set of classes whose goal is to facilitate working
with existing CloudFormation templates in the CDK.
It can be thought of as an extension of the capabilities of the
[`CfnInclude` class](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_core.CfnInclude.html).
## Basic usage
Assume we have a file with an existing template.
It could be in JSON format, in a file `my-template.json`:
```json
{
"Resources": {
"Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": "amzn-s3-demo-bucket"
}
}
}
}
```
Or it could by in YAML format, in a file `my-template.yaml`:
```yaml
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: amzn-s3-demo-bucket
```
It can be included in a CDK application with the following code:
```ts
const cfnTemplate = new cfn_inc.CfnInclude(this, 'Template', {
templateFile: 'my-template.json',
});
```
Or, if your template uses YAML:
```ts
const cfnTemplate = new cfn_inc.CfnInclude(this, 'Template', {
templateFile: 'my-template.yaml',
});
```
**Note**: different YAML parsers sometimes don't agree on what exactly constitutes valid YAML.
If you get a YAML exception when including your template,
try converting it to JSON, and including that file instead.
If you're downloading your template from the CloudFormation AWS Console,
you can easily get it in JSON format by clicking the 'View in Designer'
button on the 'Template' tab -
once in Designer, select JSON in the "Choose template language"
radio buttons on the bottom pane.
This will add all resources from `my-template.json` / `my-template.yaml` into the CDK application,
preserving their original logical IDs from the template file.
Any resource from the included template can be retrieved by referring to it by its logical ID from the template.
If you know the class of the CDK object that corresponds to that resource,
you can cast the returned object to the correct type:
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
// cfnBucket is of type s3.CfnBucket
```
Note that any resources not present in the latest version of the CloudFormation schema
at the time of publishing the version of this module that you depend on,
including [Custom Resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html),
will be returned as instances of the class `CfnResource`,
and so cannot be cast to a different resource type.
Any modifications made to that resource will be reflected in the resulting CDK template;
for example, the name of the bucket can be changed:
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
cfnBucket.bucketName = 'amzn-s3-demo-bucket';
```
You can also refer to the resource when defining other constructs,
including the higher-level ones
(those whose name does not start with `Cfn`),
for example:
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
const role = new iam.Role(this, 'Role', {
assumedBy: new iam.AnyPrincipal(),
});
role.addToPolicy(new iam.PolicyStatement({
actions: ['s3:*'],
resources: [cfnBucket.attrArn],
}));
```
## Migrating templates that use Transforms
You can use this module to migrate templates that use
[CloudFormation transforms](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-macros.html) -
including the [Serverless transform](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-aws-serverless.html).
The CDK including process does not execute Transforms,
and the `cdk diff` command by default compares against the original
(meaning, unprocessed) template.
So, if you're downloading the template to include from the CloudFormation AWS Console,
make sure to download the unprocessed template
(the "View processed template" checkbox is left **unchecked**, which is the default):
![unprocessed template in the CloudFormation AWS Console](doc-images/unprocessed-template.png)
However, certain unprocessed templates can fail when used with the `CfnInclude` class.
The most common reason for the failure is that the unprocessed template can contain cycles between resources,
which get removed after the Transform is processed,
but is not allowed when being included (as pure CloudFormation does not permit cycles). To enable cycle processing behavior similar
to cloudformation, set `allowCyclicalReferences` of CfnIncludeProps to true.
When that happens, you should instead download the processed template from the CloudFormation AWS Console
(make sure the "View processed template" checkbox is **checked** in that case):
![processed template in the CloudFormation AWS Console](doc-images/processed-template.png)
When you include that processed template in your CDK application,
running `cdk diff` will now show a lot of differences with the deployed Stack,
because `cdk diff` uses the unprocessed template by default.
To alleviate that problem, you can pass the `--processed` switch to `cdk diff`,
which will make the diff command compare against the processed template of the deployed Stack,
which will give more precise results in this case.
## Converting L1 resources to L2
The resources the `getResource` method returns are what the CDK calls
[Layer 1 resources](https://docs.aws.amazon.com/cdk/latest/guide/cfn_layer.html#cfn_layer_cfn)
(like `CfnBucket`).
However, in many places in the Construct Library,
the CDK requires so-called Layer 2 resources, like `IBucket`.
There are two ways of going from an L1 to an L2 resource.
### Using`fromCfn*()` methods
This is the preferred method of converting an L1 resource to an L2.
It works by invoking a static method of the class of the L2 resource
whose name starts with `fromCfn` -
for example, for KMS Keys, that would be the `Kms.fromCfnKey()` method -
and passing the L1 instance as an argument:
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const cfnKey = cfnTemplate.getResource('Key') as kms.CfnKey;
const key = kms.Key.fromCfnKey(cfnKey);
```
This returns an instance of the `kms.IKey` type that can be passed anywhere in the CDK an `IKey` is expected.
What is more, that `IKey` instance will be mutable -
which means calling any mutating methods on it,
like `addToResourcePolicy()`,
will be reflected in the resulting template.
Note that, in some cases, the `fromCfn*()` method might not be able to create an L2 from the underlying L1.
This can happen when the underlying L1 heavily uses CloudFormation functions.
For example, if you tried to create an L2 `IKey`
from an L1 represented as this CloudFormation template:
```json
{
"Resources": {
"Key": {
"Type": "AWS::KMS::Key",
"Properties": {
"KeyPolicy": {
"Statement": [
{
"Fn::If": [
"Condition",
{
"Action": "kms:if-action",
"Resource": "*",
"Principal": "*",
"Effect": "Allow"
},
{
"Action": "kms:else-action",
"Resource": "*",
"Principal": "*",
"Effect": "Allow"
}
]
}
],
"Version": "2012-10-17"
}
}
}
}
}
```
The `Key.fromCfnKey()` method does not know how to translate that into CDK L2 concepts,
and would throw an exception.
In those cases, you need the use the second method of converting an L1 to an L2.
### Using `from*Name/Arn/Attributes()` methods
If the resource you need does not have a `fromCfn*()` method,
or if it does, but it throws an exception for your particular L1,
you need to use the second method of converting an L1 resource to L2.
Each L2 class has static factory methods with names like `from*Name()`,
`from*Arn()`, and/or `from*Attributes()`.
You can obtain an L2 resource from an L1 by passing the correct properties of the L1 as the arguments to those methods:
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
// using from*Name()
const cfnBucket = cfnTemplate.getResource('Bucket') as s3.CfnBucket;
const bucket = s3.Bucket.fromBucketName(this, 'L2Bucket', cfnBucket.ref);
// using from*Arn()
const cfnKey = cfnTemplate.getResource('Key') as kms.CfnKey;
const key = kms.Key.fromKeyArn(this, 'L2Key', cfnKey.attrArn);
// using from*Attributes()
declare const privateCfnSubnet1: ec2.CfnSubnet;
declare const privateCfnSubnet2: ec2.CfnSubnet;
const cfnVpc = cfnTemplate.getResource('Vpc') as ec2.CfnVPC;
const vpc = ec2.Vpc.fromVpcAttributes(this, 'L2Vpc', {
vpcId: cfnVpc.ref,
availabilityZones: core.Fn.getAzs(),
privateSubnetIds: [privateCfnSubnet1.ref, privateCfnSubnet2.ref],
});
```
As long as they just need to be referenced,
and not changed in any way, everything should work;
however, note that resources returned from those methods,
unlike those returned by `fromCfn*()` methods,
are immutable, which means calling any mutating methods on them will have no effect.
You will have to mutate the underlying L1 in order to change them.
## Non-resource template elements
In addition to resources,
you can also retrieve and mutate all other template elements:
* [Parameters](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html):
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const param: core.CfnParameter = cfnTemplate.getParameter('MyParameter');
// mutating the parameter
param.default = 'MyDefault';
```
* [Conditions](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html):
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const condition: core.CfnCondition = cfnTemplate.getCondition('MyCondition');
// mutating the condition
condition.expression = core.Fn.conditionEquals(1, 2);
```
* [Mappings](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/mappings-section-structure.html):
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const mapping: core.CfnMapping = cfnTemplate.getMapping('MyMapping');
// mutating the mapping
mapping.setValue('my-region', 'AMI', 'ami-04681a1dbd79675a5');
```
* [Service Catalog template Rules](https://docs.aws.amazon.com/servicecatalog/latest/adminguide/reference-template_constraint_rules.html):
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const rule: core.CfnRule = cfnTemplate.getRule('MyRule');
// mutating the rule
declare const myParameter: core.CfnParameter;
rule.addAssertion(core.Fn.conditionContains(['m1.small'], myParameter.valueAsString),
'MyParameter has to be m1.small');
```
* [Outputs](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html):
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const output: core.CfnOutput = cfnTemplate.getOutput('MyOutput');
// mutating the output
declare const cfnBucket: s3.CfnBucket;
output.value = cfnBucket.attrArn;
```
* [Hooks for blue-green deployments](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/blue-green.html):
```ts
declare const cfnTemplate: cfn_inc.CfnInclude;
const hook: core.CfnHook = cfnTemplate.getHook('MyOutput');
// mutating the hook
declare const myRole: iam.Role;
const codeDeployHook = hook as core.CfnCodeDeployBlueGreenHook;
codeDeployHook.serviceRole = myRole.roleArn;
```
## Parameter replacement
If your existing template uses CloudFormation Parameters,
you may want to remove them in favor of build-time values.
You can do that using the `parameters` property:
```ts
new cfn_inc.CfnInclude(this, 'includeTemplate', {
templateFile: 'path/to/my/template',
parameters: {
'MyParam': 'my-value',
},
});
```
This will replace all references to `MyParam` with the string `'my-value'`,
and `MyParam` will be removed from the 'Parameters' section of the resulting template.
## Nested Stacks
This module also supports templates that use [nested stacks](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-nested-stacks.html).
For example, if you have the following parent template:
```json
{
"Resources": {
"ChildStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"TemplateURL": "https://my-s3-template-source.s3.amazonaws.com/child-stack.json"
}
}
}
}
```
where the child template pointed to by `https://my-s3-template-source.s3.amazonaws.com/child-stack.json` is:
```json
{
"Resources": {
"MyBucket": {
"Type": "AWS::S3::Bucket"
}
}
}
```
You can include both the parent stack,
and the nested stack in your CDK application as follows:
```ts
const parentTemplate = new cfn_inc.CfnInclude(this, 'ParentStack', {
templateFile: 'path/to/my-parent-template.json',
loadNestedStacks: {
'ChildStack': {
templateFile: 'path/to/my-nested-template.json',
},
},
});
```
Here, `path/to/my-nested-template.json`
represents the path on disk to the downloaded template file from the original template URL of the nested stack
(`https://my-s3-template-source.s3.amazonaws.com/child-stack.json`).
In the CDK application,
this file will be turned into an [Asset](https://docs.aws.amazon.com/cdk/latest/guide/assets.html),
and the `TemplateURL` property of the nested stack resource
will be modified to point to that asset.
The included nested stack can be accessed with the `getNestedStack` method:
```ts
declare const parentTemplate: cfn_inc.CfnInclude;
const includedChildStack = parentTemplate.getNestedStack('ChildStack');
const childStack: core.NestedStack = includedChildStack.stack;
const childTemplate: cfn_inc.CfnInclude = includedChildStack.includedTemplate;
```
Now you can reference resources from `ChildStack`,
and modify them like any other included template:
```ts
declare const childTemplate: cfn_inc.CfnInclude;
const cfnBucket = childTemplate.getResource('MyBucket') as s3.CfnBucket;
cfnBucket.bucketName = 'amzn-s3-demo-bucket1';
const role = new iam.Role(this, 'MyRole', {
assumedBy: new iam.AccountRootPrincipal(),
});
role.addToPolicy(new iam.PolicyStatement({
actions: [
's3:GetObject*',
's3:GetBucket*',
's3:List*',
],
resources: [cfnBucket.attrArn],
}));
```
You can also include the nested stack after the `CfnInclude` object was created,
instead of doing it on construction:
```ts
declare const parentTemplate: cfn_inc.CfnInclude;
const includedChildStack = parentTemplate.loadNestedStack('ChildTemplate', {
templateFile: 'path/to/my-nested-template.json',
});
```
## Vending CloudFormation templates as Constructs
In many cases, there are existing CloudFormation templates that are not entire applications,
but more like specialized fragments, implementing a particular pattern or best practice.
If you have templates like that,
you can use the `CfnInclude` class to vend them as CDK Constructs:
```ts nofixture
import { Construct } from 'constructs';
import * as cfn_inc from 'aws-cdk-lib/cloudformation-include';
import * as path from 'path';
export class MyConstruct extends Construct {
constructor(scope: Construct, id: string) {
super(scope, id);
// include a template inside the Construct
new cfn_inc.CfnInclude(this, 'MyConstruct', {
templateFile: path.join(__dirname, 'my-template.json'),
preserveLogicalIds: false, // <--- !!!
});
}
}
```
Notice the `preserveLogicalIds` parameter -
it makes sure the logical IDs of all the included template elements are re-named using CDK's algorithm,
guaranteeing they are unique within your application.
Without that parameter passed,
instantiating `MyConstruct` twice in the same Stack would result in duplicated logical IDs.

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

View File

@@ -0,0 +1 @@
export * from './lib';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.CfnInclude=void 0,Object.defineProperty(exports,_noFold="CfnInclude",{enumerable:!0,configurable:!0,get:()=>{var value=require("./lib").CfnInclude;return Object.defineProperty(exports,_noFold="CfnInclude",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,234 @@
import { Construct } from 'constructs';
import * as core from '../../core';
/**
* Construction properties of `CfnInclude`.
*/
export interface CfnIncludeProps {
/**
* Path to the template file.
*
* Both JSON and YAML template formats are supported.
*/
readonly templateFile: string;
/**
* Whether the resources should have the same logical IDs in the resulting CDK template
* as they did in the original CloudFormation template file.
* If you're vending a Construct using an existing CloudFormation template,
* make sure to pass this as `false`.
*
* **Note**: regardless of whether this option is true or false,
* the `CfnInclude.getResource` and related methods always uses the original logical ID of the resource/element,
* as specified in the template file.
*
* @default true
*/
readonly preserveLogicalIds?: boolean;
/**
* Specifies the template files that define nested stacks that should be included.
*
* If your template specifies a stack that isn't included here, it won't be created as a NestedStack
* resource, and it won't be accessible from the `CfnInclude.getNestedStack` method
* (but will still be accessible from the `CfnInclude.getResource` method).
*
* If you include a stack here with an ID that isn't in the template,
* or is in the template but is not a nested stack,
* template creation will fail and an error will be thrown.
*
* @default - no nested stacks will be included
*/
readonly loadNestedStacks?: {
[stackName: string]: CfnIncludeProps;
};
/**
* Specifies parameters to be replaced by the values in this mapping.
* Any parameters in the template that aren't specified here will be left unmodified.
* If you include a parameter here with an ID that isn't in the template,
* template creation will fail and an error will be thrown.
*
* If you are importing a parameter from a live stack, we cannot know the value of that
* parameter. You will need to supply a value for your parameters, else the default
* value will be used.
*
* @default - parameters will retain their original definitions
*/
readonly parameters?: {
[parameterName: string]: any;
};
/**
* Specifies whether to allow cyclical references, effectively disregarding safeguards meant to avoid undeployable
* templates. This should only be set to true in the case of templates utilizing cloud transforms (e.g. SAM) that
* after processing the transform will no longer contain any circular references.
*
* @default - will throw an error on detecting any cyclical references
*/
readonly allowCyclicalReferences?: boolean;
/**
* Specifies a list of LogicalIDs for resources that will be included in the CDK Stack,
* but will not be parsed and converted to CDK types. This allows you to use CFN templates
* that rely on Intrinsic placement that `cfn-include`
* would otherwise reject, such as non-primitive values in resource update policies.
*
* @default - All resources are hydrated
*/
readonly dehydratedResources?: string[];
}
/**
* The type returned from `CfnInclude.getNestedStack`.
* Contains both the NestedStack object and
* CfnInclude representations of the child stack.
*/
export interface IncludedNestedStack {
/**
* The NestedStack object which represents the scope of the template.
*/
readonly stack: core.NestedStack;
/**
* The CfnInclude that represents the template, which can
* be used to access Resources and other template elements.
*/
readonly includedTemplate: CfnInclude;
}
/**
* 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.
*/
export declare class CfnInclude extends core.CfnElement {
private readonly conditions;
private readonly conditionsScope;
private readonly resources;
private readonly parameters;
private readonly parametersToReplace;
private readonly mappingsScope;
private readonly mappings;
private readonly rules;
private readonly rulesScope;
private readonly hooks;
private readonly hooksScope;
private readonly outputs;
private readonly nestedStacks;
private readonly nestedStacksToInclude;
private readonly template;
private readonly preserveLogicalIds;
private readonly allowCyclicalReferences;
private readonly dehydratedResources;
private logicalIdToPlaceholderMap;
constructor(scope: Construct, id: string, props: CfnIncludeProps);
/**
* 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.
*
* @param logicalId the logical ID of the resource in the CloudFormation template file
*/
getResource(logicalId: string): core.CfnResource;
/**
* 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.
*
* @param conditionName the name of the Condition in the CloudFormation template file
*/
getCondition(conditionName: string): core.CfnCondition;
/**
* 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.
*
* @param parameterName the name of the parameter to retrieve
*/
getParameter(parameterName: string): core.CfnParameter;
/**
* 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.
*
* @param mappingName the name of the Mapping in the template to retrieve
*/
getMapping(mappingName: string): core.CfnMapping;
/**
* 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.
*
* @param logicalId the name of the output to retrieve
*/
getOutput(logicalId: string): core.CfnOutput;
/**
* 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.
*
* @param ruleName the name of the Rule in the CloudFormation template
*/
getRule(ruleName: string): core.CfnRule;
/**
* 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.
*
* @param hookLogicalId the logical ID of the Hook in the included CloudFormation template's 'Hooks' section
*/
getHook(hookLogicalId: string): core.CfnHook;
/**
* 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.
*
* @param logicalId the ID of the stack to retrieve, as it appears in the template
*/
getNestedStack(logicalId: string): IncludedNestedStack;
/**
* 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.
*
* @param logicalId the ID of the stack to retrieve, as it appears in the template
* @param nestedStackProps the properties of the included child Stack
* @returns the same `IncludedNestedStack` object that `getNestedStack` returns for this logical ID
*/
loadNestedStack(logicalId: string, nestedStackProps: CfnIncludeProps): IncludedNestedStack;
/** @internal */
_toCloudFormation(): object;
private createMapping;
private createParameter;
private createRule;
private createHook;
private createOutput;
private getOrCreateCondition;
private getPlaceholderID;
private getOrCreateResource;
private createNestedStack;
private parametersForNestedStack;
private timeoutForNestedStack;
private overrideLogicalIdIfNeeded;
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
/**
* Returns the fully-qualified name
* (that is, including the NPM package name)
* of a class that corresponds to this CloudFormation type,
* or undefined if the given type was not found.
*
* For example, lookup("AWS::S3::Bucket")
* returns "aws-cdk-lib/aws-s3.CfnBucket".
*/
export declare function lookup(cfnType: string): string | undefined;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.lookup=lookup;var path=()=>{var tmp=require("path");return path=()=>tmp,tmp},futils=()=>{var tmp=require("./file-utils");return futils=()=>tmp,tmp};let cfnTypeToL1Mapping;function lookup(cfnType){return cfnTypeToL1Mapping||(cfnTypeToL1Mapping=loadCfnTypeToL1Mapping()),cfnTypeToL1Mapping[cfnType]}function loadCfnTypeToL1Mapping(){return futils().readJsonSync(path().join(__dirname,"..","cfn-types-2-classes.json"))}

View File

@@ -0,0 +1,2 @@
export declare function readJsonSync(filePath: string): any;
export declare function readYamlSync(filePath: string): any;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.readJsonSync=readJsonSync,exports.readYamlSync=readYamlSync;var fs=()=>{var tmp=require("fs");return fs=()=>tmp,tmp},yaml_cfn=()=>{var tmp=require("./private/yaml-cfn");return yaml_cfn=()=>tmp,tmp};function readJsonSync(filePath){const fileContents=fs().readFileSync(filePath);return JSON.parse(fileContents.toString())}function readYamlSync(filePath){const fileContents=fs().readFileSync(filePath);return yaml_cfn().deserialize(fileContents.toString())}

View File

@@ -0,0 +1 @@
export * from './cfn-include';

View File

@@ -0,0 +1 @@
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});var _noFold;exports.CfnInclude=void 0,Object.defineProperty(exports,_noFold="CfnInclude",{enumerable:!0,configurable:!0,get:()=>{var value=require("./cfn-include").CfnInclude;return Object.defineProperty(exports,_noFold="CfnInclude",{enumerable:!0,configurable:!0,value}),value}});

View File

@@ -0,0 +1,15 @@
/**
* Serializes the given data structure into valid YAML.
*
* @param obj the data structure to serialize
* @returns a string containing the YAML representation of {@param obj}
*/
export declare function serialize(obj: any): string;
/**
* Deserialize the YAML into the appropriate data structure.
*
* @param str the string containing YAML
* @returns the data structure the YAML represents
* (most often in case of CloudFormation, an object)
*/
export declare function deserialize(str: string): any;

View File

@@ -0,0 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.serialize=serialize,exports.deserialize=deserialize;var yaml=()=>{var tmp=require("yaml");return yaml=()=>tmp,tmp},yaml_types=()=>{var tmp=require("yaml/types");return yaml_types=()=>tmp,tmp};function serialize(obj){const oldFold=yaml_types().strOptions.fold.lineWidth;try{return yaml_types().strOptions.fold.lineWidth=0,yaml().stringify(obj,{schema:"yaml-1.1"})}finally{yaml_types().strOptions.fold.lineWidth=oldFold}}function deserialize(str){return parseYamlStrWithCfnTags(str)}function makeTagForCfnIntrinsic(intrinsicName,addFnPrefix){return{identify(value){return typeof value=="string"},tag:`!${intrinsicName}`,resolve:(_doc,cstNode)=>{const ret={};return ret[addFnPrefix?`Fn::${intrinsicName}`:intrinsicName]=parseYamlStrWithCfnTags(cstNode.toString().substring(intrinsicName.length+1)),ret}}}const shortForms=["Base64","Cidr","FindInMap","GetAZs","ImportValue","Join","Sub","Select","Split","Transform","And","Equals","If","Not","Or","GetAtt"].map(name=>makeTagForCfnIntrinsic(name,!0)).concat(makeTagForCfnIntrinsic("Ref",!1),makeTagForCfnIntrinsic("Condition",!1));function parseYamlStrWithCfnTags(text){return yaml().parse(text,{customTags:shortForms,schema:"core"})}