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

CDKコントリビュートの最初の壁を越えよう! -簡単issueの見つけ方-

CDKコントリビュートの最初の壁を越えよう! -簡単issueの見つけ方-

JAWS UG CDK支部 #13

CDKコントリビュートに取り組んでみたい人向けに、おすすめのissue探し方法を紹介しています。
これを元に取り組む内容を決め、Issue起票&PR発行してみてください!

kazuho cryer-shinozuka

April 24, 2024
Tweet

Other Decks in Programming

Transcript

  1. 自作 ニキシー管温湿度気圧計 (シュタゲのあれです) クライヤー篠塚 一帆 @nixieminton @badmintoncryer @ New Zealand

    (Mount Cook) 事業会社でうすーくひろーく ソフトウェアエンジニアをしています。 AWS Community Builder (Dev Tools) AWS CDK Star Contributor 42 contributions 35 / 1412 contributors AWS SAPro / IPA SC, ES バドミントンと電子工作が好きです! キャリア18年! 毎年全国大会出てます 2
  2. 注意 対象となる人 - 「CDK contributeに興味があるけど、難しそう...」 - 「choreやdocsでcontributeしたけど、  そろそろfeatureでやってみたい」 対象でない人 -

    『エスケープハッチが必要なパラメータを、  それ無しでも設定できるように修正する』PRを作成できる人 レベル - CDK 初中級者向けです - 「思ったより簡単そう!私もcontributeしてみよう!」 と1人でも感じて頂けたら本望です 5
  3. おさらい https://aws.amazon.com/jp/blogs/aws/boost-your-infrastructure-with-cdk/ CDKアプリケーションの構成 - App - Stack - Construct Constructの構成

    - L1 (Low level) - Cloudformationリソースと1対1対応 - 自動生成 - Cfn更新に自動追従 - L2 (High level) - L1を抽象化 - 型、関数、引数チェック、etc.. を提供 - みんなのPRで更新 - L3 (Pattern) - 複数のL1, L2を更に抽象化 12
  4. 使い方 export interface CfnQueueProps { readonly delaySeconds?: number; readonly fifoQueue?:

    boolean; readonly fifoThroughputLimit?: string; } export class CfnQueue extends cdk.CfnResource { public constructor(scope: Construct, id: string, props: CfnQueueProps = {}) { super(scope, id); this.delaySeconds = props.delaySeconds; this.fifoQueue = props.fifoQueue; this.fifoThroughputLimit = props.fifoThroughputLimit; } } Cfnの各propertyがCfnQueuePropsに列挙されている (ただし、型情報は心もとない) L1の基本構成 (SQS Queue) aws-cdk-lib/aws-sqs/lib/sqs.generated.ts (一部改変) AWS::SQS::Queue の Cloudformation document 0-900の整数 boolean (true / false) ‘perQueue’ or ‘perMessageGroupId’の文字列 new sqs.CfnQueue(this, 'Resource', { delaySeconds: 256, fifoQueue: true, fifoThroughputLimit: ‘perQueue’, }); 13
  5. 使い方 export enum FifoThroughputLimit { PER_QUEUE = 'perQueue', PER_MESSAGE_GROUP_ID =

    'perMessageGroupId', } export interface QueueProps { readonly fifo?: boolean; readonly fifoThroughputLimit?: FifoThroughputLimit; } export class Queue extends QueueBase { constructor(scope: Construct, id: string, props: QueueProps = {}) { const queue = new CfnQueue(this, 'Resource', { fifoQueue: props.fifo, fifoThroughputLimit: props.fifoThroughputLimit }); } } L2の基本構成 (SQS Queue) aws-cdk-lib/aws-sqs/lib/queue.ts (一部改変) L2用のQueuePropsを定義 QueuePropsを受けとり L1(new CfnQueue())を呼び出す new sqs.Queue(this, 'Resource', { fifoQueue: true, fifoThroughputLimit: sqs.FifoThroughputLimit.PER_QUEUE, }); enumで型安全にstringを渡せる あれ?delaySecondsは?? 14
  6. L2未対応の引数 export class Queue extends QueueBase { constructor( scope: Construct,

    id: string, props: QueueProps = {} ) { const queue = new CfnQueue(this, 'Resource', { fifoQueue: props.fifo, fifoThroughputLimit: props.fifoThroughputLimit, delaySeconds: props.delaySeconds, // 本来はあるはず }); } } L2 (sqs.Queue) L1コンストラクトに delaySecondsが渡されていない! export interface CfnQueueProps { readonly delaySeconds?: number; readonly fifoQueue?: boolean; readonly fifoThroughputLimit?: string; } L1 (sqs.CfnQueue) L2が未対応、すなわちcontribute大チャンスです QueueProps CfnQueueProps L1 (CfnQueue) L2 (Queue) fifoThroughputLimit (FifoThroughputLimit) fifoQueue (boolean) delaySeconds (number) 存在しない! fifoThroughputLimit (string) fifoQueue (boolean) delaySeconds (number) 15
  7. EFSにおけるOne-Zone File Systemの有効化 Multi-Zone File System One-Zone File System new

    efs.CfnFileSystem(this, 'Resource', { vpc, }); new efs.CfnFileSystem(this, 'Resource', { vpc, availabilityZoneName: ‘ap-northeast-1a’, }); いい感じの引数をL2に追加し、これを解消するPRを作成 L2から設定不可能!(当時) 19
  8. 実装内容 vpc (ec2.IVpc) FileSystemProps その他引数 availabilityZoneName (string) CfnFileSystemProps availabilityZoneName (string)

    mount target 作成に利用 L1 (CfnFileSystem) L2 (FileSystem) その他引数 vpc (ec2.IVpc) FileSystemProps その他引数 oneZone (boolean) CfnFileSystemProps availabilityZoneName (string) mount target 作成に利用 L1 (CfnFileSystem) L2 (FileSystem) その他引数 AZ名を抽出 レビュー L1よりも、ユーザが使いやすい形式にL2の引数を設定 20 ‘ap-northeast-1a’ ‘ap-northeast-1a’ ‘ap-northeast-1a’ true
  9. L2引数のおすすめ形式チートシート Cfnの引数 L1 L2 L1への渡し方 boolean boolean boolean そのまま ARN,

    Name ex. roleArn, bucketName string Interface ex. iam.IRole, s3.IBucket Interfaceのメソッドやプロパティ呼び出し ex. iam.IRole.roleArn, s3.IBucket.bucketName 時間 ex. timeoutInSeconds number Duration ex. new Duration.minutes(5) Duration.toMethod() ex. duration.toSeconds() 特定の文字列 ex. ‘perQueue’ or ‘perMessageGroupId’ string enum ex. Hoge.PER_QUEUE そのまま S3URIなど ex. s3://bucket-name/prefix string オブジェクト ex. { bucket: IBucket, prefix: string, } bucket.urlForObject(prefix)でURI生成 JSON any オブジェクト、独自classなど いい感じに頑張る レビュワーと相談しながら、使いやすい形式を考えてみてください! L2の引数は、よりユーザが使いやすい形式に自由に変えちゃいましょう!! 22
  10. L2未対応引数詰め合わせ (v2.137.0) rds.DbCluster allocatedStorage, autoMinorVersionUpgrade, availavilityZones, dbClusterInstanceClass, dbSystemId, enableGlobalWriteForwarding ,

    engineMode, iops, performanceInsightsEnabled, performanceInsightsKmsKeyId, performanceInsightsRetentionPeriod, publiclyAccessible, restoreToTime, restoreType, useLatestRestorableTime apigateway.RestApi mode, body apigatewayv2.HttpApi basePath, body, bodyS3Location, credentialsArn, failOnWarnings, routeKey, target, version apigatewayv2.WebSocketApi disableSchemaValidation, failOnWarnings, version apsync.GraphQLApi enhancedMetricsConfig, ownerContact certificateManager.Certificate certificateAuthorityArn cloudfront.DistributionConfig cNAMEs, continuousDeploymentPolicyId, customOrigin, s3Origin, staging, cloudtrail.Trail advancedEventSelectors codebuild.Project resourceAccessRole, visibility, ec2.Instance additionalInfo, affinity, cpuOptions, disableApiTermination, ebsOptimized, elasticGpuSpecifications, elasticInferenceAccelerators, enclaveOptions, hibernationOptions, hostId, histResourceGroupArn, InstanceInitiatedShutdownBehavior, ipv6AddressCount, ipv6Addreses, kernelId, launchTemplate, licenseSpecifications, placementGroupName, privateDnsNameOptions, ramdiskId, securityGroups, ssmAssociations, tenancy, volumes, ... and much more!! 23
  11. まとめ CDKにcontributeしてみたい!でもissueがみつからないよ... - docs, chore(インスタンスタイプ, エンジンバージョン追加)が簡単 - L2への引数追加もハードル低め!たくさんPRチャンスがあります L2の引数は自由に定義可能 -

    安易なstringは避けよう - ✕ ‘arn:aws:iam::123456789012:role/IamRoleName ‘ - ◯ iam.IRoleを渡し、L2内でIRole.roleArnを呼び出す - Interface, enum, オブジェクト, 独自classなど、使い勝手が良いものを! 皆様もぜひCDK contributeデビューしてみてください!! 24