Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.stack.templateOptions.transforms = [ 'AWS::Serverless-2016-10-31' ]; // required for AWS::Serverless
const resource = new CfnResource(this, 'Resource', {
type: 'AWS::Serverless::Application',
properties: {
Location: {
ApplicationId: KUBECTL_APP_ARN,
SemanticVersion: version
},
Parameters: {
LayerName: `kubectl-${uniqueId}`
}
}
});
this.layerVersionArn = Token.asString(resource.getAtt('Outputs.LayerVersionArn'));
}
protected prepareCrossReference(sourceStack: Stack, reference: Reference): IResolvable {
const targetStack = Stack.of(reference.target);
// the nested stack references a resource from the parent stack:
// we pass it through a as a cloudformation parameter
if (targetStack === sourceStack.nestedStackParent) {
// we call "this.resolve" to ensure that tokens do not creep in (for example, if the reference display name includes tokens)
const paramId = this.resolve(`reference-to-${reference.target.node.uniqueId}.${reference.displayName}`);
let param = this.node.tryFindChild(paramId) as CfnParameter;
if (!param) {
param = new CfnParameter(this, paramId, { type: 'String' });
this.parameters[param.logicalId] = Token.asString(reference);
}
return param.value;
}
// parent stack references a resource from the nested stack:
// we output it from the nested stack and use "Fn::GetAtt" as the reference value
if (targetStack === this && targetStack.nestedStackParent === sourceStack) {
return this.getCreateOutputForReference(reference);
}
// sibling nested stacks (same parent):
// output from one and pass as parameter to the other
if (targetStack.nestedStackParent && targetStack.nestedStackParent === sourceStack.nestedStackParent) {
const outputValue = this.getCreateOutputForReference(reference);
return (sourceStack as NestedStack).prepareCrossReference(sourceStack, outputValue);
private contextualAttribute(innerValue: string, outerValue: string) {
return Token.asString({
resolve: (context: IResolveContext) => {
if (Stack.of(context.scope) === this) {
return innerValue;
} else {
return outerValue;
}
}
});
}
}
function artifactGetParam(artifact: Artifact, jsonFile: string, keyName: string) {
const lazyArtifactName = Lazy.stringValue({ produce: () => artifact.artifactName });
return Token.asString({ 'Fn::GetParam': [lazyArtifactName, jsonFile, keyName] });
}
function artifactAttribute(artifact: Artifact, attributeName: string) {
const lazyArtifactName = Lazy.stringValue({ produce: () => artifact.artifactName });
return Token.asString({ 'Fn::GetArtifactAtt': [lazyArtifactName, attributeName] });
}
handler.addToRolePolicy(new iam.PolicyStatement({
actions: [ 'iam:PassRole' ],
resources: [ props.roleArn ]
}));
const resource = new cfn.CustomResource(this, 'Resource', {
resourceType: ClusterResource.RESOURCE_TYPE,
provider: cfn.CustomResourceProvider.lambda(handler),
properties: {
Config: props
}
});
this.ref = resource.ref;
this.attrEndpoint = Token.asString(resource.getAtt('Endpoint'));
this.attrArn = Token.asString(resource.getAtt('Arn'));
this.attrCertificateAuthorityData = Token.asString(resource.getAtt('CertificateAuthorityData'));
this.creationRole = handler.role!;
}
}
public toString() {
return Token.asString(this, { displayHint: this.displayHint });
}
public getAttString(attributeName: string): string {
return Token.asString(this.getAtt(attributeName));
}
}