Git Product home page Git Product logo

kikoda-cdk-constructs's Introduction

Kikoda CDK Constructs Library

License npm version NuGet version

Use this Kikoda CDK Constructs Library to architect and model modern applications deployed with AWS CDK.

Install from NPM:

yarn add --dev @kikoda/cdk-constructs

# or

npm install @kikoda/cdk-constructs --save-dev

Usage

AWS CDK

The Kikoda Constructs library currently only supports AWS CDK v2.

Add this to your CDK stack to create a new Cloudfront/S3 backed website:

import { Website } from '@kikoda/cdk-constructs';

const website = new Website(this, 'Website', {
  stage: <DEPLOYMENT_STAGE_NAME>,
  appDir: resolve(__dirname, <RELATIVE_PATH_TO_WEB_ASSETS>),
  buildDir: <BUILD_DIR_RELATIVE_TO_APP_DIR>,
  buildCommand: <CMD_TO_BUILD_APP>,
  domainName: <DOMAIN_NAME>,
});

Configured Stages

With the ConfiguredStage construct you can pass arbitrary environmental configuration to your CDK App. This is useful when you want to define and use a configuration object in your nested Stacks and Constructs.

import { CodePipeline } from 'aws-cdk-lib/pipeines';
import { ConfiguredStage } from '@kikoda/cdk-constructs';

interface Config {
  foo: string;
}

class MyStack extends Stack {
  constructor(scope: Construct, id: string) {
    super(scope, id);

    /*
     * Get a config value in a child stack or construct
     */
    const stage = ConfiguredStage.extOf(this) as ConfiguredStage<Config>;

    const new MyConstruct(this, 'MyConstruct', {
      foo: stage.config.foo,
    });
  }
}

class MyStage<T> extends ConfiguredStage<T> {
  constructor(scope: Construct, id: string, props: ConfiguredStageProps<T>) {
    super(scope, id, props);

    new MyStack(this, 'MyStack');
  }
}

/*
 * Use the stage with CDK Pipelines
 */
const stage = new MyStage<Config>(this, 'DevStage', {
  stageName: 'dev',
  config: {
    foo: 'bar',
  },
});

const pipeline = new CodePipeline(this, 'Pipeline', {
  synth: new ShellStep('Synth', {
    input: CodePipelineSource.gitHub('owner/repo', 'main'),
    commands: [
      'yarn install',
      'yarn build',
      'npx cdk synth',
    ],
  }),
});

pipeline.addStage(stage);

Opening Issues

If you encounter a bug with this package, we want to hear about it. Before opening a new issue, search the existing issues to avoid duplicates.

When opening an issue, include the Kikoda Construct Library version, Node version, and stack trace if available. In addition, include the steps to reproduce when appropriate.

You can also open an issue for a feature request.

Contributing

If you find an issue with this package and have a fix, please feel free to open a pull request following the procedures.

Testing

If you contribute to this package you can run the tests using yarn test.

License

Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.

This product includes software developed at Kikoda (https://www.kikoda.com). Copyright 2022 Kikoda, LLC.

kikoda-cdk-constructs's People

Contributors

apogeeoak avatar bmh16e avatar hikeeba avatar nathantcz avatar projen-workflows[bot] avatar tj-harris avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

kikoda-cdk-constructs's Issues

index: Export Existing Constructs

Describe the feature

A few existing constructs are not currently exported but possibly should be.

  • AssumeRolePartialBuildSpec
  • CodeArtifactAuthTokenAccessRole
  • SinglePageApp

Use Case

The referenced constructs should be evaluated to see if they should be exported for use by consumers of the library.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Library version used

0.6.2

Environment details (OS name and version, etc.)

N/A

defineSynthCommands: yarn install command is malformed.

Describe the bug

The defineSynthCommands when creating the command array for a yarn lockfile produces an invalid command array.

Expected Behavior

This should be generated as \"yarn install --no-immutable\",\n

Current Behavior

\"yarn\",\n \"install\",\n \"--no-immutable\",\n
These commands will be run as yarn && install && --no-immutable

Reproduction Steps

Create a branch-pipeline construct that deploys a cdk app with a yarn.lock.

Possible Solution

No response

Additional Information/Context

No response

Library Version

No response

Node.js Version

16

OS

Linux

Language

Typescript

Language Version

No response

Other information

No response

bug: policy to allow assume role of builder not properly setting resource.

An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::123:assumed-role/core-development-pipeline-coredevelopmentAssetsDoc-167WVS97NSSIO/AWSCodeBuild-ef1dc2da-a082-4b08-a997-a6dc444b7352 is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::123:role/core-development-pipeline-CodeArtifactsAccessRole6-TCR01DSH2SW3

Website: add option to specify environment variables for bundling.

Describe the feature

We require the option to add an environment variable that the build script requires for preparing our assets.

Use Case

Our react build depends on a private GitHub package that requires a token specified at build time. I would like to keep this token in AWS Secrets. The only way to accomplish this right now is to override the current bundling for the Website construct. I would rather just add an environment variable.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Library version used

0.3.64

Environment details (OS name and version, etc.)

n/a

Remove dependency on JQ from assume-role-partial-build-spec.ts

The assume-role-partial-build-spec.ts has a dependency on the jq linux package. As not all linux distros ship with this package it is possible that this functionality would not work properly on some docker images.
See assume-role-partial-build-spec.ts line 33.
'export AWS_ACCESS_KEY_ID=$(echo "${TEMP_ROLE}" | jq -r \'.Credentials.AccessKeyId\')'

SinglePageApp: Remove references to DnsValidatedCertificate, a deprecated construct

Describe the bug

DnsValidatedCertificate has been deprecated in aws-cdk-lib.

Expected Behavior

No deprecation warnings when using the SinglePageApp construct.

Current Behavior

When SinglePageApp is included in a stack the following deprecation warning appears:

[WARNING] aws-cdk-lib.aws_certificatemanager.DnsValidatedCertificate is deprecated.
  use {@link Certificate } instead
  This API will be removed in the next major release.

Reproduction Steps

Create a stack that includes SinglePageApp.

Possible Solution

No response

Additional Information/Context

No response

Library Version

No response

Node.js Version

all

OS

all

Language

Typescript

Language Version

No response

Other information

No response

metadata: Add Description to GitHub

Describe the feature

Add a description to the GitHub repository.

Use Case

Increase discoverability of the library.

Proposed Solution

Possible descriptions:

  • Use this Kikoda CDK Constructs Library to architect and model modern applications deployed with AWS CDK.
  • High level constructs to architect and model modern applications deployed with AWS CDK.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Library version used

0.6.2

Environment details (OS name and version, etc.)

N/A

Add configuration option for package manager.

Synth commands are created based on a hard coded package manager. We need to expose this as a property so that other package managers can be used. See component-pipeline-stack.ts
defineSynthCommands('npm', baseDir, synthOuputDir)

pipeline-event-notification-rule: PipelineEventNotificationRule Should Accept `id` Parameter

Describe the feature

PipelineEventNotificationRule should accept an id parameter instead of using a static string for the id.

Use Case

Creating two PipelineEventNotificationRule constructs in the same scope will throw an exception.

Proposed Solution

Update the constructor signature to include an id parameter to allow different PipelineEventNotificationRules to be uniquely identified.

Other Information

-  constructor(scope: CodePipeline, props: PipelineEventNotificationRuleProps) {
+  constructor(scope: CodePipeline, id: string, props: PipelineEventNotificationRuleProps) {
-    const targetTopic = Topic.fromTopicArn(scope, 'NotificationTopic', props.notificationTopicArn);
+    const targetTopic = Topic.fromTopicArn(scope, `NotificationTopic-${id}`, props.notificationTopicArn);
-    super(scope, `Pipeline-Event-Notification`, ruleProperties);
+    super(scope, `Pipeline-Event-Notification-${id}`, ruleProperties);

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Library version used

0.6.2

Environment details (OS name and version, etc.)

N/A

code-source: Misspelled Public API Property `RepositoryConfig.synthOuputDir`

Describe the bug

The public API property RepositoryConfig.synthOuputDir is misspelled.

Expected Behavior

RepositoryConfig.synthOuputDir is correctly spelled RepositoryConfig.synthOutputDir.

Current Behavior

N/A

Reproduction Steps

N/A

Possible Solution

  • Leave synthOuputDir misspelled, potentially with a note stating that it is left misspelled.
  • Deprecate synthOuputDir and create a new property synthOutputDir referring to the same value.
  • Rename synthOuputDir to synthOutputDir without deprecating synthOuputDir first.

Additional Information/Context

No response

Library Version

0.6.2

Node.js Version

N/A

OS

N/A

Language

Typescript, Python, .NET

Language Version

No response

Other information

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.