Skip to content

shazi7804/terraform-cdk-examples

Repository files navigation

CDK on Terraform Deploy Multiple Cloud samples

Table of contents

Architecture

Architecture Diagram

This architecture includes multi-cloud deployment, refer to AWS, Azure and Google architecture for details.

architecture

Deployment Steps

Step 1. Install Terraform and CDK on Terraform

  • Install Terraform (MacOS)
$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform
$ terraform version
  • Install cdktf
$ npm install -g cdktf-cli
$ cdktf --version

Step 2. Define your environment variables

You can refer config/default.json to define environment variables.

  • Customize common tags for all resources.
{
    "Tags": {
        "CreateBy": "cdktf",
        "Owner": "<your-name>"
    }
}
  • Customize network subnet with multiple cloud.
{
    "Providers": {
        "Aws": {
            "Regions": ["us-east-1"],
            "Vpc": {
                "cidr": "10.0.0.0/16",
                "privateSubnets": [
                    "10.0.0.0/21",
                    "10.0.8.0/21"
                ],
                "publicSubnets": [
                    "10.0.16.0/21",
                    "10.0.24.0/21"
                ],
        "Azure": {
            "Regions": ["eastus"],
            "Network": {
                "cidr": "10.0.0.0/16",
                "privateSubnets": [
                    "10.0.0.0/21",
                    "10.0.8.0/21"
                ],
                "publicSubnets": [
                    "10.0.16.0/21",
                    "10.0.24.0/21"
                ]
            }
        }
    }
}
  • Customize kubernetes with multiple cloud.
{
    "Providers": {
        "Aws": {
            "Eks": {
                "name": "cdktf",
                "instanceType": ["m4.large"],
                "instanceCount": 1,
                "version": "1.18"
            }
        },
        "Azure": {
            "Aks": {
                "name": "cdktf",
                "instanceType": ["Standard_D2_v2"],
                "instanceCount": 1,
                "dnsPrefix": "cdktf-kubernetes",
                "version": "1.17.11"
            }
        }
    }
}

Step 3. Create an execution plan

$ cdktf plan

Step 4. Deploy the changes configuration

$ cdktf deploy

If you like the style of terraform output, you can execute make plan && make deploy. more detail reference Makefile

Parameters

You can customize environment parameters in config/default.json

Parameters Description
StackName The parameter of this stack name. default is cdktf
Tags The parameter of this stack common tags. default is { "CreateBy": "cdktf", "SampleFrom": "https://github.com/shazi7804" }
Providers The parameter of providers of this stack.

Releases

No releases published

Packages

No packages published