Created
August 5, 2020 13:20
-
-
Save Tirke/74c089a8b0c275853a47d706446fd9b7 to your computer and use it in GitHub Desktop.
simple-cdk-tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Construct} from 'constructs'; | |
import {App, TerraformOutput, TerraformStack} from 'cdktf'; | |
import {AwsProvider, LambdaFunction, IamRole} from "./.gen/providers/aws"; | |
class MyStack extends TerraformStack { | |
constructor(scope: Construct, id: string) { | |
super(scope, id); | |
new AwsProvider(this, "aws", { | |
region: "eu-west-1", | |
}); | |
const lambdaRole = new IamRole(this, "cdk-tf-lambda-role", { | |
name: "cdk-tf-lambda-role", | |
assumeRolePolicy: JSON.stringify({ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
} | |
] | |
}) | |
}) | |
const lambda = new LambdaFunction(this, "cdk-tf-lambda", { | |
filename: '../lambda/lambda.zip', | |
functionName: 'cdk-tf', | |
handler: 'index.handler', | |
role: lambdaRole.arn, | |
runtime: 'nodejs12.x' | |
}); | |
new TerraformOutput(this, 'cdk-tf-lambda-arn', { | |
value: lambda.arn | |
}); | |
} | |
} | |
const app = new App(); | |
new MyStack(app, 'dec-imp'); | |
app.synth(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment