Slide 1

Slide 1 text

Contributing to Construct Hub with projen JAWS-UG CDK #1 June 1st, 2022 Hayato Kosugi

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

Recommend developing with projen 6

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

• 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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

.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: '30886141+hayao-k@users.noreply.github.com', 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();

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Happy Constructing! 15