0.6.18 • Published 6 days ago

projen-cdktf-hybrid-construct v0.6.18

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
6 days ago

Projen-CDKTF-Hybrid-Construct

Status: Tech Preview Releases LICENSE build

Projen template for CDKTF Constructs that should also be used as Terraform Modules and for republishing Terraform Modules as Constructs.

projen-cdktf-hybrid-construct is in technical preview, which means it's a community supported project. It still requires extensive testing and polishing to mature into a HashiCorp officially supported project. Please file issues generously and detail your experience while using the library. We welcome your feedback.

By using the software in this repository, you acknowledge that:

  • projen-cdktf-hybrid-construct is still in development, may change, and has not been released as a commercial product by HashiCorp and is not currently supported in any way by HashiCorp.
  • projen-cdktf-hybrid-construct is provided on an "as-is" basis, and may include bugs, errors, or other issues.
  • projen-cdktf-hybrid-construct is NOT INTENDED FOR PRODUCTION USE, use of the Software may result in unexpected results, loss of data, or other unexpected results, and HashiCorp disclaims any and all liability resulting from use of projen-cdktf-hybrid-construct.
  • HashiCorp reserves all rights to make all decisions about the features, functionality and commercial release (or non-release) of projen-cdktf-hybrid-construct, at any time and without any obligation or liability whatsoever.

Compatibility

  • cdktf >= 0.20.0
  • constructs >= 10.0.107

Usage

HybridModule

If you want to write a CDKTF construct and also publish it as a Terraform Module you can use the HybridModule template.

You can initialize such a project using npx projen new --from projen-cdktf-hybrid-construct hybrid-module.

A configuration might look like this:

const { HybridModule } = require("projen-cdktf-hybrid-construct");

const project = new HybridModule({
  // The name of the module & repository need to start with terraform-cdk-
  name: "terraform-cdk-my-new-hybrid-construct",
  repositoryUrl:
    "github.com/DanielMSchmidt/terraform-cdk-my-new-hybrid-construct",

  author: "Daniel Schmidt",
  authorAddress: "danielmschmidt92@gmail.com",

  // If enabled an example folder with terraform code will be created
  terraformExamples: {
    enabled: true,
    folder: "terraform",
    // The configuration to add to the example terraform file
    providerConfig: `
        terraform {
          required_providers {
            aws = {
              source  = "hashicorp/aws"
              version = "~> 3.74"
            }
          }
          # Terraform binary version constraint
          required_version = ">= 1.2.0"
        }
        
        
        provider "aws" {
          region = "eu-central-1"
        }
        `,
  },

  // If enabled a constructs example folder will be created
  constructExamples: {
    enabled: true,
    folder: "construct-examples",
  },
});
project.synth();

TerraformModule

If you want to republish an existing Terraform module as a CDKTF construct or if you want to repackage them with an easier to use API you can use the TerraformModule template.

You can initialize such a project using npx projen new --from projen-cdktf-hybrid-construct terraform-module.

A configutation might look like this:

const { TerraformModule } = require("projen-cdktf-hybrid-construct");

const project = new TerraformModule({
  name: "my-module",
  author: "Daniel Schmidt",
  authorAddress: "danielmschmidt92@gmail.com",
  repositoryUrl: "github.com/DanielMSchmidt/my-module",

  terraformModules: [
    {
      name: "eks",
      source: "terraform-aws-modules/eks/aws",
      version: "~> 18.0",
    },
    {
      name: "eks-managed-nodegroup",
      source: "terraform-aws-modules/eks/aws//modules/eks-managed-node-group",
      version: "~> 18.0",
    },
  ],
});

project.synth();

Publishing

Open Source

We have a helper method for easy configuration, but there are still some manual steps required.

const {
  HybridModule,
  publishToRegistries,
} = require("projen-cdktf-hybrid-construct");

const project = new HybridModule({
  // ... all the other options
  ...publishToRegistries({
    name: "my-new-hybrid-construct",
    namespace: "my-org",
    registries: ["npm", "pypi", "nuget", "maven"],
  }),
});

Terraform

  1. Sign in at the registry
  2. Select your repository and create the module

Please make sure your repository name starts with terraform-cdk-.

npm (Typescript)

  1. Create an account at npmjs.com
  2. Create an automation token on npm
  3. Create a GitHub Action Secret with the name NPM_TOKEN and the value of the token

pypi (Python)

  1. Create an account at pypi.org
  2. Create an API token on pypi
  3. Create a GitHub Action Secret with the name TWINE_USERNAME and the value __token__ and a second one with the name TWINE_PASSWORD and the value of the token
  4. Set the publishToPypi section in the options of HybridModule or TerraformModule (or use the helper mentioned above)
const name = "name-of-my-hybrid-construct";
new HybridModule({
  name,
  // ... other options
  publishToPypi: {
    distName: name,
    module: name.replace(/-/g, "_"),
  },
});

Maven (Java)

  1. Create a Sonatype account and repository
  2. Create GitHub Action Secrets to configure maven:
    • MAVEN_USERNAME
    • MAVEN_PASSWORD
    • MAVEN_STAGING_PROFILE_ID
    • MAVEN_GPG_PRIVATE_KEY_PASSPHRASE
    • MAVEN_GPG_PRIVATE_KEY_PASSPHRASE
  3. Setup the publishToMaven section in the options of HybridModule or TerraformModule (or use the helper mentioned above)
const githubNamespace = "my-org";
const name = "name-of-my-hybrid-construct";
new HybridModule({
  name,
  // ... other options
  publishToMaven: {
    javaPackage: name.replace(/-/g, "_"),
    mavenGroupId: `com.${githubNamespace}`,
    mavenArtifactId: name,
  },
});

NuGet (C#)

  1. Create a NuGet account (you might need to create a Microsoft Account if you don't have one)
  2. Create API keys
  3. Create a GitHub Action Secret with the name NUGET_API_KEY and the value of the token
  4. Setup the publishToNuget section in the options of HybridModule or TerraformModule (or use the helper mentioned above)
const githubNamespace = "my-org";
const name = "name-of-my-hybrid-construct";

new HybridModule({
  name,
  // ... other options
  publishToNuget: {
    dotNetNamespace: `MyOrg.NameOfMyHybridConstruct`,
    packageId: `MyOrg.NameOfMyHybridConstruct`,
  },
});

Github Packages

We have a helper method for easy configuration, no extra steps needed:

const {
  HybridModule,
  publishToGithubPackages,
} = require("projen-cdktf-hybrid-construct");

const project = new HybridModule({
  // ... all the other options
  ...publishToGithubPackages({
    name: "my-new-hybrid-construct",
    namespace: "my-org",
    registries: ["npm", "maven"], // pypi and nuget are not yet supported
  }),
});

Artifactory

We have a helper method for easy configuration, but there are also some manual steps required.

const {
  HybridModule,
  publishToGithubPackages,
} = require("projen-cdktf-hybrid-construct");

const project = new HybridModule({
  // ... all the other options
  ...publishToGithubPackages({
    name: "my-new-hybrid-construct",
    namespace: "my-org",
    registries: ["npm", "pypi", "nuget"], // maven is currently not supported, PRs welcome
    artifactoryApiUrl: "https://artifactory.my-org.com/api/",
    artifactoryRepository: "my-repo", // needs to be the same across all registries, defaults to namespace so "my-org" in this case
  }),
});

Terraform

You can find more information about publishing Terraform Modules to Artifactory here.

npm (Typescript)

  1. Create a virtual npm registry
  2. Authenticate against artifactory to get a token
  3. Create a GitHub Action Secret with the name NPM_TOKEN and the value of the token

pypi (Python)

  1. Create a local repository
  2. Create a GitHub Action Secret with the name TWINE_USERNAME and the artifactory user name and a second one with the name TWINE_PASSWORD and the artifactory password
0.6.18

6 days ago

0.6.17

13 days ago

0.6.16

20 days ago

0.6.15

27 days ago

0.6.14

1 month ago

0.6.13

1 month ago

0.6.12

2 months ago

0.6.11

2 months ago

0.6.10

2 months ago

0.6.9

2 months ago

0.6.8

2 months ago

0.6.7

3 months ago

0.6.6

3 months ago

0.6.5

3 months ago

0.6.4

3 months ago

0.6.3

3 months ago

0.6.2

4 months ago

0.6.1

4 months ago

0.6.0

4 months ago

0.5.15

4 months ago

0.5.14

4 months ago

0.5.13

5 months ago

0.5.12

5 months ago

0.5.10

5 months ago

0.5.11

5 months ago

0.5.8

5 months ago

0.5.7

6 months ago

0.5.9

5 months ago

0.4.10

7 months ago

0.4.11

7 months ago

0.4.12

7 months ago

0.5.4

6 months ago

0.5.3

6 months ago

0.5.6

6 months ago

0.5.5

6 months ago

0.5.0

7 months ago

0.5.2

6 months ago

0.5.1

7 months ago

0.4.9

8 months ago

0.4.8

8 months ago

0.4.7

8 months ago

0.3.4

9 months ago

0.3.3

9 months ago

0.4.5

9 months ago

0.4.4

9 months ago

0.4.6

8 months ago

0.4.1

9 months ago

0.4.0

9 months ago

0.4.3

9 months ago

0.4.2

9 months ago

0.3.2

1 year ago

0.3.0

1 year ago

0.3.1

1 year ago

0.2.0

2 years ago

0.1.52

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.56

2 years ago

0.1.57

2 years ago

0.1.58

2 years ago

0.1.59

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.49

2 years ago

0.1.41

2 years ago

0.1.42

2 years ago

0.1.43

2 years ago

0.1.44

2 years ago

0.1.45

2 years ago

0.1.46

2 years ago

0.1.47

2 years ago

0.1.48

2 years ago

0.1.40

2 years ago

0.1.38

2 years ago

0.1.39

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.1.34

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.1.37

2 years ago

0.1.70

2 years ago

0.1.27

2 years ago

0.1.28

2 years ago

0.1.29

2 years ago

0.1.63

2 years ago

0.1.64

2 years ago

0.1.65

2 years ago

0.1.66

2 years ago

0.1.67

2 years ago

0.1.68

2 years ago

0.1.69

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.60

2 years ago

0.1.61

2 years ago

0.1.62

2 years ago

0.1.24

2 years ago

0.1.23

2 years ago

0.1.22

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago