Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Contributing to Construct Hub with projen

hayao_k
June 03, 2022

Contributing to Construct Hub with projen

I spoke at the CDK chapter of the Japan AWS User Group about contributing to Construct Hub using projen.

hayao_k

June 03, 2022
Tweet

More Decks by hayao_k

Other Decks in Technology

Transcript

  1. About Me • Cloud Engineer @ Saison Information Systems •

    AWS Community Builder (Fall of 2020) • 2019 - 2022 APN AWS Top Engineers in Japan • 11x AWS Certified 2 @hayaok3 @hayao-k
  2. What is Construct Hub? • Registry for discovering and sharing

    Construct Libraries published by community, AWS, and AWS partners. • December 2021 - GA on same date as AWS CDK v2 • More than 1k Construct Libraries available • https://constructs.dev/ 3
  3. How to get listed on Construct Hub • JSII-compatible •

    For multi-language support • Open-source license • Apache, BSD, EPL, MPL-2.0, ISC, and CDDL or MIT • Published to npm Registry with CDK Keyword • cdk, awscdk, aws-cdk, cdk8s, or cdktf • Meet requirements, appear in Construct Hub in 30 minutes 4
  4. 5

  5. Problems when developing with TypeScript • Management of project configurations

    has become more complex in recent years • For TypeScript Project • package.json, tsconfig.json, .gitignore, eslint, jest, etc. • Learn by example but difficult 7
  6. What is Projen? • A new generation of project generators

    • Applied construct programming model to project configuration • Tools to define and maintain project configurations in code • projen manages configuration files such as package.json and tsconfig.json, etc. • Manage them continuously (Not only create) • https://github.com/projen/projen 8
  7. • node - Node.js project. • project - Base project.

    • python - Python project. • react - React project without TypeScript. • react-ts - React project with TypeScript. • typescript - TypeScript project. • typescript-app - TypeScript app. Built-in Project types • awscdk-app-java - AWS CDK app in Java. • awscdk-app-py - AWS CDK app in Python. • awscdk-app-ts - AWS CDK app in TypeScript. • awscdk-construct - AWS CDK construct library project. • cdk8s-app-ts - CDK8s app in TypeScript. • cdk8s-construct - CDK8s construct library project. • cdktf-construct - CDKTF construct library project. • java - Java project. • jsii - Multi-language jsii library project. • nextjs - Next.js project without TypeScript. • nextjs-ts - Next.js project with TypeScript. 9 $ mkdir awesome-project $ cd awesome-project $ git init $ npx projen new PROJECT-TYPE 🤖 Synthesizing project... awscdk-construct is project type for creating jsii-compatible construct library
  8. Create Construct Library project • projen new awscdk-construct • Files

    required for development are generated. • package.json, tsconfig, GitHub Actions Workflow, etc. • Customize settings in .projenrc.js • Minimum CDK versions to support • Dependencies with other libraries • Library name in each package manager, etc. 10
  9. .projenrc.js example 11 • Apply changes with projen command •

    No manual editing • Build fails if edited manually • e.g., publishToPypi • python added to jsii configuration in package.json • Step to publish to PyPI added to release.yml (GitHub Actions) API Reference https://projen.io/api/API.html#projen-awscdk-awscdkconstructlibrary const { awscdk } = require('projen'); const cdkVersion = '2.25.0'; const project = new awscdk.AwsCdkConstructLibrary({ author: 'hayao-k', authorAddress: '[email protected]', cdkVersion, defaultReleaseBranch: 'main', name: 'cdk-sample-lib', repositoryUrl: 'https://github.com/hayao-k/cdk-sample-lib.git', description: 'Sample AWS CDK Construct Library by projen', keywords: ['sample'], license: 'Apache-2.0', deps: [ `@aws-cdk/aws-apigatewayv2-alpha@${cdkVersion}-alpha.0`, `@aws-cdk/aws-apigatewayv2-integrations-alpha@${cdkVersion}-alpha.0`, 'other-useful-lib' ], publishToPypi: { distName: 'cdk-sample-lib', module: 'cdk_sample_lib', }, }); project.synth();
  10. Easily automated release • Build workflow (.github/workflows/build.yml) • Run at

    creating a pull request • Tampering checks and building library • Release workflow (.github/workflows/release.yml) • Run at push to release branch • Tampering checks and building library • Semantic Versioning with Conventional Commits • Publish to GitHub Releases, each language registry 12
  11. Guide with sample code • A Beginner's Guide to Create

    AWS CDK Construct Library with projen • https://dev.to/aws-builders/a-beginner-s- guide-to-create-aws-cdk-construct-library- with-projen-5eh4 • Featured on Construct Hub!! 13
  12. Summary • Construct Hub • Construct Hub is a place

    to discover CDK constructs • Many useful libraries • We can publish our library • projen • Dramatically eases project configuration management and CI/CD • Easily publish your libraries to Construct Hub • Awesome developer experience 14