Skip to content

Commit

Permalink
refactor: bump cdkv2
Browse files Browse the repository at this point in the history
  • Loading branch information
maekawataiki committed Feb 10, 2023
1 parent 58656cf commit 2412579
Show file tree
Hide file tree
Showing 10 changed files with 1,861 additions and 2,918 deletions.
15 changes: 9 additions & 6 deletions .projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ const project = new awscdk.AwsCdkConstructLibrary({
author: 'Pahud Hsieh',
authorAddress: 'pahudnet@gmail.com',
description: 'CDK construct library that allows you to create KeyCloak service on AWS in TypeScript or Python',
cdkVersion: '2.1.0',
cdkVersion: '2.64.0',
jsiiFqn: 'projen.AwsCdkConstructLibrary',
name: 'cdk-keycloak',
majorVersion: 2,
repositoryUrl: 'https://github.com/aws-samples/cdk-keycloak.git',
// devDeps: [
// '@types/prettier@<2.6.0',
Expand Down
58 changes: 29 additions & 29 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ __Extends__: [Construct](#constructs-construct)
new Database(scope: Construct, id: string, props: DatabaseProps)
```

* **scope** (<code>[Construct](#aws-cdk-core-construct)</code>) *No description*
* **scope** (<code>[Construct](#constructs-construct)</code>) *No description*
* **id** (<code>string</code>) *No description*
* **props** (<code>[DatabaseProps](#cdk-keycloak-databaseprops)</code>) *No description*
* **vpc** (<code>[IVpc](#aws-cdk-aws-ec2-ivpc)</code>) The VPC for the database.
* **vpc** (<code>[aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc)</code>) The VPC for the database.
* **auroraServerless** (<code>boolean</code>) enable aurora serverless. __*Default*__: false
* **auroraServerlessV2** (<code>boolean</code>) enable aurora serverless v2. __*Default*__: false
* **backupRetention** (<code>[Duration](#aws-cdk-core-duration)</code>) database backup retension. __*Default*__: 7 days
* **clusterEngine** (<code>[IClusterEngine](#aws-cdk-aws-rds-iclusterengine)</code>) The database cluster engine. __*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
* **databaseSubnets** (<code>[SubnetSelection](#aws-cdk-aws-ec2-subnetselection)</code>) VPC subnets for database. __*Optional*__
* **instanceEngine** (<code>[IInstanceEngine](#aws-cdk-aws-rds-iinstanceengine)</code>) The database instance engine. __*Default*__: MySQL 8.0.21
* **instanceType** (<code>[InstanceType](#aws-cdk-aws-ec2-instancetype)</code>) The database instance type. __*Default*__: r5.large
* **backupRetention** (<code>[Duration](#aws-cdk-lib-duration)</code>) database backup retension. __*Default*__: 7 days
* **clusterEngine** (<code>[aws_rds.IClusterEngine](#aws-cdk-lib-aws-rds-iclusterengine)</code>) The database cluster engine. __*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
* **databaseSubnets** (<code>[aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)</code>) VPC subnets for database. __*Optional*__
* **instanceEngine** (<code>[aws_rds.IInstanceEngine](#aws-cdk-lib-aws-rds-iinstanceengine)</code>) The database instance engine. __*Default*__: MySQL 8.0.21
* **instanceType** (<code>[aws_ec2.InstanceType](#aws-cdk-lib-aws-ec2-instancetype)</code>) The database instance type. __*Default*__: r5.large
* **singleDbInstance** (<code>boolean</code>) Whether to use single RDS instance rather than RDS cluster. __*Default*__: false


Expand Down Expand Up @@ -126,27 +126,27 @@ __Extends__: [Construct](#constructs-construct)
new KeyCloak(scope: Construct, id: string, props: KeyCloakProps)
```

* **scope** (<code>[Construct](#aws-cdk-core-construct)</code>) *No description*
* **scope** (<code>[Construct](#constructs-construct)</code>) *No description*
* **id** (<code>string</code>) *No description*
* **props** (<code>[KeyCloakProps](#cdk-keycloak-keycloakprops)</code>) *No description*
* **certificateArn** (<code>string</code>) ACM certificate ARN to import.
* **keycloakVersion** (<code>[KeycloakVersion](#cdk-keycloak-keycloakversion)</code>) The Keycloak version for the cluster.
* **auroraServerless** (<code>boolean</code>) Whether to use aurora serverless. __*Default*__: false
* **auroraServerlessV2** (<code>boolean</code>) Whether to use aurora serverless v2. __*Default*__: false
* **autoScaleTask** (<code>[AutoScaleTask](#cdk-keycloak-autoscaletask)</code>) Autoscaling for the ECS Service. __*Default*__: no ecs service autoscaling
* **backupRetention** (<code>[Duration](#aws-cdk-core-duration)</code>) database backup retension. __*Default*__: 7 days
* **backupRetention** (<code>[Duration](#aws-cdk-lib-duration)</code>) database backup retension. __*Default*__: 7 days
* **bastion** (<code>boolean</code>) Create a bastion host for debugging or trouble-shooting. __*Default*__: false
* **clusterEngine** (<code>[IClusterEngine](#aws-cdk-aws-rds-iclusterengine)</code>) The database cluster engine. __*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
* **databaseInstanceType** (<code>[InstanceType](#aws-cdk-aws-ec2-instancetype)</code>) Database instance type. __*Default*__: r5.large
* **databaseSubnets** (<code>[SubnetSelection](#aws-cdk-aws-ec2-subnetselection)</code>) VPC subnets for database. __*Default*__: VPC isolated subnets
* **clusterEngine** (<code>[aws_rds.IClusterEngine](#aws-cdk-lib-aws-rds-iclusterengine)</code>) The database cluster engine. __*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
* **databaseInstanceType** (<code>[aws_ec2.InstanceType](#aws-cdk-lib-aws-ec2-instancetype)</code>) Database instance type. __*Default*__: r5.large
* **databaseSubnets** (<code>[aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)</code>) VPC subnets for database. __*Default*__: VPC isolated subnets
* **env** (<code>Map<string, string></code>) The environment variables to pass to the keycloak container. __*Optional*__
* **instanceEngine** (<code>[IInstanceEngine](#aws-cdk-aws-rds-iinstanceengine)</code>) The database instance engine. __*Default*__: MySQL 8.0.21
* **instanceEngine** (<code>[aws_rds.IInstanceEngine](#aws-cdk-lib-aws-rds-iinstanceengine)</code>) The database instance engine. __*Default*__: MySQL 8.0.21
* **nodeCount** (<code>number</code>) Number of keycloak node in the cluster. __*Default*__: 2
* **privateSubnets** (<code>[SubnetSelection](#aws-cdk-aws-ec2-subnetselection)</code>) VPC private subnets for keycloak service. __*Default*__: VPC private subnets
* **publicSubnets** (<code>[SubnetSelection](#aws-cdk-aws-ec2-subnetselection)</code>) VPC public subnets for ALB. __*Default*__: VPC public subnets
* **privateSubnets** (<code>[aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)</code>) VPC private subnets for keycloak service. __*Default*__: VPC private subnets
* **publicSubnets** (<code>[aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)</code>) VPC public subnets for ALB. __*Default*__: VPC public subnets
* **singleDbInstance** (<code>boolean</code>) Whether to use single RDS instance rather than RDS cluster. __*Default*__: false
* **stickinessCookieDuration** (<code>[Duration](#aws-cdk-core-duration)</code>) The sticky session duration for the keycloak workload with ALB. __*Default*__: one day
* **vpc** (<code>[IVpc](#aws-cdk-aws-ec2-ivpc)</code>) VPC for the workload. __*Optional*__
* **stickinessCookieDuration** (<code>[Duration](#aws-cdk-lib-duration)</code>) The sticky session duration for the keycloak workload with ALB. __*Default*__: one day
* **vpc** (<code>[aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc)</code>) VPC for the workload. __*Optional*__



Expand All @@ -170,14 +170,14 @@ addDatabase(props: DatabaseProps): Database
```

* **props** (<code>[DatabaseProps](#cdk-keycloak-databaseprops)</code>) *No description*
* **vpc** (<code>[IVpc](#aws-cdk-aws-ec2-ivpc)</code>) The VPC for the database.
* **vpc** (<code>[aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc)</code>) The VPC for the database.
* **auroraServerless** (<code>boolean</code>) enable aurora serverless. __*Default*__: false
* **auroraServerlessV2** (<code>boolean</code>) enable aurora serverless v2. __*Default*__: false
* **backupRetention** (<code>[Duration](#aws-cdk-core-duration)</code>) database backup retension. __*Default*__: 7 days
* **clusterEngine** (<code>[IClusterEngine](#aws-cdk-aws-rds-iclusterengine)</code>) The database cluster engine. __*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
* **databaseSubnets** (<code>[SubnetSelection](#aws-cdk-aws-ec2-subnetselection)</code>) VPC subnets for database. __*Optional*__
* **instanceEngine** (<code>[IInstanceEngine](#aws-cdk-aws-rds-iinstanceengine)</code>) The database instance engine. __*Default*__: MySQL 8.0.21
* **instanceType** (<code>[InstanceType](#aws-cdk-aws-ec2-instancetype)</code>) The database instance type. __*Default*__: r5.large
* **backupRetention** (<code>[Duration](#aws-cdk-lib-duration)</code>) database backup retension. __*Default*__: 7 days
* **clusterEngine** (<code>[aws_rds.IClusterEngine](#aws-cdk-lib-aws-rds-iclusterengine)</code>) The database cluster engine. __*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
* **databaseSubnets** (<code>[aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)</code>) VPC subnets for database. __*Optional*__
* **instanceEngine** (<code>[aws_rds.IInstanceEngine](#aws-cdk-lib-aws-rds-iinstanceengine)</code>) The database instance engine. __*Default*__: MySQL 8.0.21
* **instanceType** (<code>[aws_ec2.InstanceType](#aws-cdk-lib-aws-ec2-instancetype)</code>) The database instance type. __*Default*__: r5.large
* **singleDbInstance** (<code>boolean</code>) Whether to use single RDS instance rather than RDS cluster. __*Default*__: false

__Returns__:
Expand Down Expand Up @@ -311,14 +311,14 @@ Name | Type | Description

Name | Type | Description
-----|------|-------------
**vpc** | <code>[IVpc](#aws-cdk-aws-ec2-ivpc)</code> | The VPC for the database.
**vpc** | <code>[aws_ec2.IVpc](#aws-cdk-lib-aws-ec2-ivpc)</code> | The VPC for the database.
**auroraServerless**? | <code>boolean</code> | enable aurora serverless.<br/>__*Default*__: false
**auroraServerlessV2**? | <code>boolean</code> | enable aurora serverless v2.<br/>__*Default*__: false
**backupRetention**? | <code>[Duration](#aws-cdk-core-duration)</code> | database backup retension.<br/>__*Default*__: 7 days
**clusterEngine**? | <code>[IClusterEngine](#aws-cdk-aws-rds-iclusterengine)</code> | The database cluster engine.<br/>__*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
**databaseSubnets**? | <code>[SubnetSelection](#aws-cdk-aws-ec2-subnetselection)</code> | VPC subnets for database.<br/>__*Optional*__
**instanceEngine**? | <code>[IInstanceEngine](#aws-cdk-aws-rds-iinstanceengine)</code> | The database instance engine.<br/>__*Default*__: MySQL 8.0.21
**instanceType**? | <code>[InstanceType](#aws-cdk-aws-ec2-instancetype)</code> | The database instance type.<br/>__*Default*__: r5.large
**backupRetention**? | <code>[Duration](#aws-cdk-lib-duration)</code> | database backup retension.<br/>__*Default*__: 7 days
**clusterEngine**? | <code>[aws_rds.IClusterEngine](#aws-cdk-lib-aws-rds-iclusterengine)</code> | The database cluster engine.<br/>__*Default*__: rds.AuroraMysqlEngineVersion.VER_2_09_1
**databaseSubnets**? | <code>[aws_ec2.SubnetSelection](#aws-cdk-lib-aws-ec2-subnetselection)</code> | VPC subnets for database.<br/>__*Optional*__
**instanceEngine**? | <code>[aws_rds.IInstanceEngine](#aws-cdk-lib-aws-rds-iinstanceengine)</code> | The database instance engine.<br/>__*Default*__: MySQL 8.0.21
**instanceType**? | <code>[aws_ec2.InstanceType](#aws-cdk-lib-aws-ec2-instancetype)</code> | The database instance type.<br/>__*Default*__: r5.large
**singleDbInstance**? | <code>boolean</code> | Whether to use single RDS instance rather than RDS cluster.<br/>__*Default*__: false


Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

CDK construct library that allows you to create [KeyCloak](https://www.keycloak.org/) on AWS in TypeScript or Python

> **Note**
>
> This project have been migrated to CDK v2.
>
> CDK v1 compatible version is deprecated now.
# Sample

```ts
Expand Down
14 changes: 7 additions & 7 deletions package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions src/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ export interface KeyCloakProps {
*/
readonly auroraServerless?: boolean;
/**
* Whether to use aurora serverless v2. When enabled, the `databaseInstanceType` and
* `engine` will be ignored.
* Whether to use aurora serverless v2. When enabled, the `databaseInstanceType` will be ignored.
*
* @default false
*/
Expand Down Expand Up @@ -456,9 +455,8 @@ export class Database extends Construct {
// create a RDS for MySQL DB cluster with Aurora Serverless v2
private _createServerlessV2Cluster(props: DatabaseProps): DatabaseCofig {
const dbCluster = new rds.DatabaseCluster(this, 'DBCluster', {
engine: rds.DatabaseClusterEngine.auroraMysql({
// Engine Version Manually Specified since Aurora MySQL 3.02.0 is not listed in CDK v1 currently
version: { auroraMysqlFullVersion: '8.0.mysql_aurora.3.02.0', auroraMysqlMajorVersion: '8.0', _combineImportAndExportRoles: true } as rds.AuroraMysqlEngineVersion,
engine: props.clusterEngine ?? rds.DatabaseClusterEngine.auroraMysql({
version: rds.AuroraMysqlEngineVersion.VER_3_02_0,
}),
defaultDatabaseName: 'keycloak',
deletionProtection: true,
Expand Down
34 changes: 34 additions & 0 deletions test/__snapshots__/integ.snapshot.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ test('with aurora serverless v2', () => {
});

// THEN
expect(stack).toHaveResource('AWS::RDS::DBCluster', {
const t = assertions.Template.fromStack(stack);
t.hasResourceProperties('AWS::RDS::DBCluster', {
Engine: 'aurora-mysql',
DBClusterParameterGroupName: 'default.aurora-mysql8.0',
DBSubnetGroupName: {
Expand Down Expand Up @@ -219,15 +220,15 @@ test('with aurora serverless v2', () => {
],
});
// we should have 2 db instances in the cluster
expect(stack).toCountResources('AWS::RDS::DBInstance', 2);
t.resourceCountIs('AWS::RDS::DBInstance', 2);
// we should have db instance with db.serverless instance class
expect(stack).toHaveResource('AWS::RDS::DBInstance', {
t.hasResourceProperties('AWS::RDS::DBInstance', {
DBInstanceClass: 'db.serverless',
});
// we should have 2 secrets
expect(stack).toCountResources('AWS::SecretsManager::Secret', 2);
t.resourceCountIs('AWS::SecretsManager::Secret', 2);
// we should have ecs service
expect(stack).toHaveResource('AWS::ECS::Service', {
t.hasResourceProperties('AWS::ECS::Service', {
Cluster: {
Ref: 'KeyCloakKeyCloakContainerSerivceClusterA18E44FF',
},
Expand Down
Loading

0 comments on commit 2412579

Please sign in to comment.