Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
super(scope, id, { env: { account: parentStack.account, region: parentStack.region } });
// @deprecate: remove this in v2.0 (redundent)
const parentScope = new Construct(scope, id + '.NestedStack');
Object.defineProperty(this, NESTED_STACK_SYMBOL, { value: true });
// this is the file name of the synthesized template file within the cloud assembly
this.templateFile = `${this.node.uniqueId}.nested.template.json`;
this.parameters = props.parameters || {};
this.resource = new CfnStack(parentScope, `${id}.NestedStackResource`, {
templateUrl: this.templateUrl,
parameters: Lazy.anyValue({ produce: () => Object.keys(this.parameters).length > 0 ? this.parameters : undefined }),
notificationArns: props.notifications ? props.notifications.map(n => n.topicArn) : undefined,
timeoutInMinutes: props.timeout ? props.timeout.toMinutes() : undefined,
});
this.nestedStackResource = this.resource;
// context-aware stack name: if resolved from within this stack, return AWS::StackName
// if resolved from the outer stack, use the { Ref } of the AWS::CloudFormation::Stack resource
// which resolves the ARN of the stack. We need to extract the stack name, which is the second
// component after splitting by "/"
this._contextualStackName = this.contextualAttribute(Aws.STACK_NAME, Fn.select(1, Fn.split('/', this.resource.ref)));
this._contextualStackId = this.contextualAttribute(Aws.STACK_ID, this.resource.ref);
}
new kms.Alias(this, 'ArtifactsBucketEncryptionKeyAlias', {
aliasName: this.generateNameForDefaultBucketKeyAlias(),
targetKey: encryptionKey,
removalPolicy: RemovalPolicy.DESTROY, // destroy the alias along with the key
});
}
this.artifactBucket = propsBucket;
// If a role has been provided, use it - otherwise, create a role.
this.role = props.role || new iam.Role(this, 'Role', {
assumedBy: new iam.ServicePrincipal('codepipeline.amazonaws.com')
});
const codePipeline = new CfnPipeline(this, 'Resource', {
artifactStore: Lazy.anyValue({ produce: () => this.renderArtifactStoreProperty() }),
artifactStores: Lazy.anyValue({ produce: () => this.renderArtifactStoresProperty() }),
stages: Lazy.anyValue({ produce: () => this.renderStages() }),
roleArn: this.role.roleArn,
restartExecutionOnUpdate: props && props.restartExecutionOnUpdate,
name: this.physicalName,
});
// this will produce a DependsOn for both the role and the policy resources.
codePipeline.node.addDependency(this.role);
this.artifactBucket.grantReadWrite(this.role);
this.pipelineName = this.getResourceNameAttribute(codePipeline.ref);
this.pipelineVersion = codePipeline.attrVersion;
this.crossRegionBucketsPassed = !!props.crossRegionReplicationBuckets;
for (const [region, replicationBucket] of Object.entries(props.crossRegionReplicationBuckets || {})) {
this._crossRegionSupport[region] = {
: (props.propagateTags !== undefined ? props.propagateTags : PropagatedTagSource.NONE);
super(scope, id, {
...props,
// If daemon, desiredCount must be undefined and that's what we want. Otherwise, default to 1.
desiredCount: props.daemon || props.desiredCount !== undefined ? props.desiredCount : 1,
maxHealthyPercent: props.daemon && props.maxHealthyPercent === undefined ? 100 : props.maxHealthyPercent,
minHealthyPercent: props.daemon && props.minHealthyPercent === undefined ? 0 : props.minHealthyPercent,
launchType: LaunchType.EC2,
propagateTags: propagateTagsFromSource,
enableECSManagedTags: props.enableECSManagedTags,
},
{
cluster: props.cluster.clusterName,
taskDefinition: props.taskDefinition.taskDefinitionArn,
placementConstraints: Lazy.anyValue({ produce: () => this.constraints }, { omitEmptyArray: true }),
placementStrategies: Lazy.anyValue({ produce: () => this.strategies }, { omitEmptyArray: true }),
schedulingStrategy: props.daemon ? 'DAEMON' : 'REPLICA',
}, props.taskDefinition);
this.constraints = [];
this.strategies = [];
this.daemon = props.daemon || false;
if (props.taskDefinition.networkMode === NetworkMode.AWS_VPC) {
this.configureAwsVpcNetworking(props.cluster.vpc, props.assignPublicIp, props.vpcSubnets, props.securityGroup);
} else {
// Either None, Bridge or Host networking. Copy SecurityGroup from ASG.
validateNoNetworkingProps(props);
this.connections.addSecurityGroup(...props.cluster.connections.securityGroups);
}
constructor(scope: Construct, id: string, props: SecurityGroupProps) {
super(scope, id, {
physicalName: props.securityGroupName
});
const groupDescription = props.description || this.node.path;
this.allowAllOutbound = props.allowAllOutbound !== false;
this.securityGroup = new CfnSecurityGroup(this, 'Resource', {
groupName: this.physicalName,
groupDescription,
securityGroupIngress: Lazy.anyValue({ produce: () => this.directIngressRules}, { omitEmptyArray: true} ),
securityGroupEgress: Lazy.anyValue({ produce: () => this.directEgressRules }, { omitEmptyArray: true} ),
vpcId: props.vpc.vpcId,
});
this.securityGroupId = this.securityGroup.attrGroupId;
this.securityGroupVpcId = this.securityGroup.attrVpcId;
this.securityGroupName = this.securityGroup.ref;
this.addDefaultEgressRule();
}
private evaluateHealthGracePeriod(providedHealthCheckGracePeriod?: Duration): IResolvable {
return Lazy.anyValue({
produce: () => providedHealthCheckGracePeriod !== undefined ? providedHealthCheckGracePeriod.toSeconds() :
this.loadBalancers.length > 0 ? 60 :
undefined
});
}
}
constructor(scope: Construct, id: string, props: RuleProps = { }) {
super(scope, id, {
physicalName: props.ruleName,
});
this.description = props.description;
const resource = new CfnRule(this, 'Resource', {
name: this.physicalName,
description: this.description,
state: props.enabled == null ? 'ENABLED' : (props.enabled ? 'ENABLED' : 'DISABLED'),
scheduleExpression: Lazy.stringValue({ produce: () => this.scheduleExpression }),
eventPattern: Lazy.anyValue({ produce: () => this.renderEventPattern() }),
targets: Lazy.anyValue({ produce: () => this.renderTargets() }),
});
this.ruleArn = this.getResourceArnAttribute(resource.attrArn, {
service: 'events',
resource: 'rule',
resourceName: this.physicalName,
});
this.addEventPattern(props.eventPattern);
this.scheduleExpression = props.schedule && props.schedule.expressionString;
for (const target of props.targets || []) {
this.addTarget(target);
}
}
if (props.lambdaTriggers) {
for (const t of Object.keys(props.lambdaTriggers)) {
const trigger = props.lambdaTriggers[t];
if (trigger !== undefined) {
this.addLambdaPermission(trigger as lambda.IFunction, t);
(this.triggers as any)[t] = (trigger as lambda.IFunction).functionArn;
}
}
}
const userPool = new CfnUserPool(this, 'Resource', {
userPoolName: this.physicalName,
usernameAttributes,
aliasAttributes,
autoVerifiedAttributes: props.autoVerifiedAttributes,
lambdaConfig: Lazy.anyValue({ produce: () => this.triggers })
});
this.userPoolId = this.getResourceNameAttribute(userPool.ref);
this.userPoolArn = this.getResourceArnAttribute(userPool.attrArn, {
service: 'cognito',
resource: 'userpool',
resourceName: this.physicalName,
});
this.userPoolProviderName = userPool.attrProviderName;
this.userPoolProviderUrl = userPool.attrProviderUrl;
}
private synthesizeMapRoles() {
return Lazy.anyValue({
produce: () => this.stack.toJsonString(this.roleMappings.map(m => ({
rolearn: m.role.roleArn,
username: m.mapping.username,
groups: m.mapping.groups
})))
});
}
physicalName: props.bucketName,
});
const { bucketEncryption, encryptionKey } = this.parseEncryption(props);
this.validateBucketName(this.physicalName);
const resource = new CfnBucket(this, 'Resource', {
bucketName: this.physicalName,
bucketEncryption,
versioningConfiguration: props.versioned ? { status: 'Enabled' } : undefined,
lifecycleConfiguration: Lazy.anyValue({ produce: () => this.parseLifecycleConfiguration() }),
websiteConfiguration: this.renderWebsiteConfiguration(props),
publicAccessBlockConfiguration: props.blockPublicAccess,
metricsConfigurations: Lazy.anyValue({ produce: () => this.parseMetricConfiguration() }),
corsConfiguration: Lazy.anyValue({ produce: () => this.parseCorsConfiguration() }),
accessControl: props.accessControl,
});
resource.applyRemovalPolicy(props.removalPolicy);
this.versioned = props.versioned;
this.encryptionKey = encryptionKey;
this.bucketName = this.getResourceNameAttribute(resource.ref);
this.bucketArn = this.getResourceArnAttribute(resource.attrArn, {
region: '',
account: '',
service: 's3',
resource: this.physicalName,
});