cdktf-web
v1.0.0
Published
cdktf and its major providers for browsers
Downloads
2
Readme
cdktf-web
Run Terraform-CDK in the browser.
Getting Started
npm install cdktf-web
Usage
After loading the scripts in browser, the following globals are available:
CDKTF
: Exposes thecdktf
packageCONSTRUCTS
: Exposes theconstructs
packageCDKTF_PROVIDER_AWS
: Exposes the@cdktf/provider-aws
packageCDKTF_PROVIDER_GOOGLE
: Exposes the@cdktf/provider-google
packageCDKTF_PROVIDER_AZURERM
: Exposes the@cdktf/provider-azurerm
package
Load the scripts in your browser with a HTML like this:
<html>
<head>
<title>cdktf-web</title>
<script src="node_modules/cdktf-web/dist/bundle.constructs.js"></script>
<script src="node_modules/cdktf-web/dist/bundle.cdktf.js"></script>
<script src="node_modules/cdktf-web/dist/bundle.cdktf-provider-aws.js"></script>
<script src="node_modules/cdktf-web/dist/bundle.cdktf-provider-google.js"></script>
<script src="node_modules/cdktf-web/dist/bundle.cdktf-provider-azurerm.js"></script>
</head>
<body></body>
</html>
And synthesize a sample stack:
const app = new CDKTF.App();
const stack = new CDKTF.TerraformStack(app, 'MyBrowserStack');
const provider = new CDKTF_PROVIDER_AWS.provider.AwsProvider(stack, 'AWS', {region: "us-west-1"});
const ec2Instance = new CDKTF_PROVIDER_AWS.instance.Instance(stack, "compute", {
ami: "ami-01456a894f71116f2",
instanceType: "t2.micro",
});
new CDKTF.TerraformOutput(stack, "public_ip", {
value: ec2Instance.publicIp,
});
app.synth();
JSON.parse(CDKTF.fs.vol.toJSON()["/cdktf.out/stacks/MyBrowserStack/cdk.tf.json"]);