npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cdk-keycloak

v2.9.0

Published

CDK construct library that allows you to create KeyCloak service on AWS in TypeScript or Python

Downloads

96

Readme

NPM version PyPI version release

cdk-keycloak

CDK construct library that allows you to create KeyCloak on AWS in TypeScript or Python

Note

This project has been migrated to CDK v2.

CDK v1 compatible version is deprecated now.

Sample

For Keycloak 17+ versions, please specify hostname for the Keycloak server.

import { KeyCloak } from 'cdk-keycloak';

const app = new cdk.App();

const env = {
  region: process.env.CDK_DEFAULT_REGION,
  account: process.env.CDK_DEFAULT_ACCOUNT,
};

const stack = new cdk.Stack(app, 'keycloak-demo', { env });
new KeyCloak(stack, 'KeyCloak', {
  hostname: 'keycloak.example.com',
  certificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/293cf875-ca98-4c2e-a797-e1cf6df2553c',
  keycloakVersion: KeycloakVersion.V22_0_4,
});

Keycloak version pinning

Use keycloakVersion to specify the version.

new KeyCloak(stack, 'KeyCloak', {
  hostname,
  certificateArn,
  keycloakVersion: KeycloakVersion.V22_0_4,
});

To specify any other verion not defined in the construct, use KeycloakVersion.of('x.x.x'). This allows you to specify any new version as soon as it's available. However, as new versions will not always be tested and validated with this construct library, make sure you fully backup and test before you use any new version in the production environment.

Aurora Serverless support

The KeyCloak construct provisions the Amaozn RDS cluster for MySQL with 2 database instances under the hood, to opt in Amazon Aurora Serverless, use auroraServerless to opt in Amazon Aurora Serverless cluster. Please note only some regions are supported, check Supported features in Amazon Aurora by AWS Region and Aurora DB engine for availability.

// Aurora Serverless v1
new KeyCloak(stack, 'KeyCloak', {
  hostname,
  certificateArn,
  keycloakVersion,
  auroraServerless: true,
});

// Aurora Serverless v2
new KeyCloak(stack, 'KeyCloak', {
  hostname,
  certificateArn,
  keycloakVersion,
  auroraServerlessV2: true,
});

Behind the scene, a default RDS cluster for MySQL with 2 database instances will be created.

Opt-in for Single RDS instance

To create single RDS instance for your testing or development environment, use singleDbInstance to turn on the single db instance deployment.

Plesae note this is not recommended for production environment.

new KeyCloak(stack, 'KeyCloak', {
  hostname,
  certificateArn,
  keycloakVersion,
  singleDbInstance: true,
});

Service Auto Scaling

Define autoScaleTask for the ecs service task autoscaling. For example:

new KeyCloak(stack, 'KeyCloak', {
  hostname,
  certificateArn,
  keycloakVersion,
  auroraServerlessV2: true,
  nodeCount: 2,
  autoScaleTask: {
    min: 2,
    max: 10,
    targetCpuUtilization: 60,
  },
});

Customize fargate task settings

Define taskCpu or taskMemory for overriding the defaults for the ecs service task. Could be useful for development environments. For example:

new KeyCloak(stack, 'KeyCloak', {
  hostname,
  certificateArn,
  keycloakVersion,
  nodeCount: 1, 
  taskCpu: 512,
  taskMemory: 2048,
});

Deploy in existing Vpc Subnets

You can deploy the workload in the existing Vpc and subnets. The publicSubnets are for the ALB, privateSubnets for the keycloak container tasks and databaseSubnets for the database.

The best practice is to specify isolated subnets for databaseSubnets, however, in some cases might have no existing isolates subnets then the private subnets are also acceptable.

Consider the sample below:

new KeyCloak(stack, 'KeyCloak', {
  hostname: 'keycloak.example.com',
  keycloakVersion: KeycloakVersion.V22_0_4,
  certificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/293cf875-ca98-4c2e-a797-e1cf6df2553c',
  vpc: ec2.Vpc.fromLookup(stack, 'Vpc', { vpcId: 'vpc-0417e46d' }),
  publicSubnets: {
    subnets: [
      ec2.Subnet.fromSubnetId(stack, 'pub-1a', 'subnet-5bbe7b32'),
      ec2.Subnet.fromSubnetId(stack, 'pub-1b', 'subnet-0428367c'),
      ec2.Subnet.fromSubnetId(stack, 'pub-1c', 'subnet-1586a75f'),
    ],
  },
  privateSubnets: {
    subnets: [
      ec2.Subnet.fromSubnetId(stack, 'priv-1a', 'subnet-0e9460dbcfc4cf6ee'),
      ec2.Subnet.fromSubnetId(stack, 'priv-1b', 'subnet-0562f666bdf5c29af'),
      ec2.Subnet.fromSubnetId(stack, 'priv-1c', 'subnet-00ab15c0022872f06'),
    ],
  },
  databaseSubnets: {
    subnets: [
      ec2.Subnet.fromSubnetId(stack, 'db-1a', 'subnet-0e9460dbcfc4cf6ee'),
      ec2.Subnet.fromSubnetId(stack, 'db-1b', 'subnet-0562f666bdf5c29af'),
      ec2.Subnet.fromSubnetId(stack, 'db-1c', 'subnet-00ab15c0022872f06'),
    ],
  },
});

AWS China Regions

This library support AWS China regions cn-north-1 and cn-northwest-1 and will auto select local docker image mirror to accelerate the image pulling. You don't have to do anything.

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.