Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// SECRETS
const secret = new CfnSecret(
this,
"Secret",
secretProps(aurora, DB_CLUSTER_ID)
);
const secret2 = new CfnSecret(
this,
"Secret2",
secretProps(aurora2, `${DB_CLUSTER_ID}2`)
);
secret.addDependsOn(aurora);
secret2.addDependsOn(aurora2);
new CfnOutput(this, "AASASecretArn", {
value: secret.ref
});
new CfnOutput(this, "AASASecretArn2", {
value: secret2.ref
});
// TEST USER
const user = new User(this, "TestUser");
const policy = new Policy(this, "TestUserPolicy", {
statements: [
new PolicyStatement({
actions: ["rds-data:*"],
resources: [
`arn:aws:rds:${this.region}:${this.account}:cluster:${DB_CLUSTER_ID}*`,
`arn:aws:rds:${this.region}:${this.account}:cluster:${DB_CLUSTER_ID}2*`
const enableLogging = props.enableLogging !== undefined ? props.enableLogging : true;
this.logDriver = props.logDriver !== undefined
? props.logDriver
: enableLogging
? this.createAWSLogDriver(this.node.id)
: undefined;
// Add the queue name to environment variables
this.environment = { ...(props.environment || {}), QUEUE_NAME: this.sqsQueue.queueName };
this.secrets = props.secrets;
// Determine the desired task count (minimum) and maximum scaling capacity
this.desiredCount = props.desiredTaskCount || 1;
this.maxCapacity = props.maxScalingCapacity || (2 * this.desiredCount);
new CfnOutput(this, 'SQSQueue', { value: this.sqsQueue.queueName });
new CfnOutput(this, 'SQSQueueArn', { value: this.sqsQueue.queueArn });
}
this.clusterName = this.getResourceNameAttribute(resource.ref);
this.clusterArn = this.getResourceArnAttribute(resource.attrArn, {
service: 'eks',
resource: 'cluster',
resourceName: this.physicalName,
});
this.clusterEndpoint = resource.attrEndpoint;
this.clusterCertificateAuthorityData = resource.attrCertificateAuthorityData;
const updateConfigCommandPrefix = `aws eks update-kubeconfig --name ${this.clusterName}`;
const getTokenCommandPrefix = `aws eks get-token --cluster-name ${this.clusterName}`;
const commonCommandOptions = [ `--region ${stack.region}` ];
if (props.outputClusterName) {
new CfnOutput(this, 'ClusterName', { value: this.clusterName });
}
// we maintain a single manifest custom resource handler per cluster since
// permissions and role are scoped. This will return `undefined` if kubectl
// is not enabled for this cluster.
this._k8sResourceHandler = this.createKubernetesResourceHandler();
// map the IAM role to the `system:masters` group.
if (props.mastersRole) {
if (!this.kubectlEnabled) {
throw new Error(`Cannot specify a "masters" role if kubectl is disabled`);
}
this.awsAuth.addMastersRole(props.mastersRole);
if (props.outputMastersRoleArn) {
});
// Internet facing load balancer for the frontend services
const externalLB = new elbv2.ApplicationLoadBalancer(this, 'external', {
vpc: vpc,
internetFacing: true
});
const externalListener = externalLB.addListener('PublicListener', { port: 80, open: true });
externalListener.addTargets('greeter', {
port: 80,
targets: [greeterService]
});
this.internalDNS = new cdk.CfnOutput(this, 'InternalDNS', {
exportName: 'greeter-app-internal',
value: internalLB.loadBalancerDnsName
});
this.externalDNS = new cdk.CfnOutput(this, 'ExternalDNS', {
exportName: 'greeter-app-external',
value: externalLB.loadBalancerDnsName
});
}
}
private getCreateOutputForReference(reference: Reference) {
const outputId = `${reference.target.node.uniqueId}${reference.displayName}`;
let output = this.node.tryFindChild(outputId) as CfnOutput;
if (!output) {
output = new CfnOutput(this, outputId, { value: Token.asString(reference) });
}
return this.resource.getAtt(`Outputs.${output.logicalId}`);
}
}),
],
});
new cdk.CfnOutput(this, 'ServiceURL', {
value: `http://${fargatesvc.loadBalancer.loadBalancerDnsName}`
})
new cdk.CfnOutput(this, 'StackId', {
value: this.stackId
})
new cdk.CfnOutput(this, 'StackName', {
value: this.stackName
})
new cdk.CfnOutput(this, 'CodeCommitRepoName', {
value: codecommitRepo.repositoryName
})
let codeCommitHint = `
Create a "imagedefinitions.json" file and git add/push into CodeCommit repository "${CODECOMMIT_REPO_NAME}" with the following value:
[
{
"name": "defaultContainer",
"imageUri": "${this.ecrRepository.repositoryUri}:latest"
}
]
`
new cdk.CfnOutput(this, 'Hint', {
value: codeCommitHint
})
[
{
"name": "defaultContainer",
"imageUri": "${this.ecrRepository.repositoryUri}:latest"
}
]
`
new cdk.CfnOutput(this, 'Hint', {
value: codeCommitHint
})
new cdk.CfnOutput(this, 'CodeBuildProjectName', {
value: CodeBuildProject.name
})
new cdk.CfnOutput(this, 'Bucket', { value: coffeeShopBucket.bucketName });
}
}
constructor(scope: Construct, id: string, props: WatchfulProps = { }) {
super(scope, id);
if (props.alarmEmail) {
this.alarmTopic = new sns.Topic(this, 'AlarmTopic', { displayName: 'Watchful Alarms' });
this.alarmTopic.addSubscription(new sns_subscriptions.EmailSubscription(props.alarmEmail));
}
this.dash = new cloudwatch.Dashboard(this, 'Dashboard');
new CfnOutput(this, 'WatchfulDashboard', {
value: linkForDashboard(this.dash)
});
}
new cdk.CfnOutput(this, 'CodeCommitRepoName', {
value: codecommitRepo.repositoryName
})
let codeCommitHint = `
Create a "imagedefinitions.json" file and git add/push into CodeCommit repository "${CODECOMMIT_REPO_NAME}" with the following value:
[
{
"name": "defaultContainer",
"imageUri": "${this.ecrRepository.repositoryUri}:latest"
}
]
`
new cdk.CfnOutput(this, 'Hint', {
value: codeCommitHint
})
new cdk.CfnOutput(this, 'CodeBuildProjectName', {
value: CodeBuildProject.name
})
new cdk.CfnOutput(this, 'Bucket', { value: coffeeShopBucket.bucketName });
}
}