Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .projen/deps.json

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

2 changes: 1 addition & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { awscdk, javascript } from 'projen';
const project = new awscdk.AwsCdkConstructLibrary({
author: 'yicr',
authorAddress: '[email protected]',
cdkVersion: '2.100.0',
cdkVersion: '2.145.0',
defaultReleaseBranch: 'main',
typescriptVersion: '5.5.x',
jsiiVersion: '5.5.x',
Expand Down
22 changes: 22 additions & 0 deletions API.md

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const codeConnectionsHostCustomResource = new CodeConnectionsHostCustomResource(
});

// get host arn
const hostArn = codeConnectionsHostCustomResource.getResponseField('HostArn');
const hostArn = gitLabSelfManagedConnectionHostCustomResource.findHostArn();

new codeconnections.CfnConnection(this, 'Connection', {
connectionName: 'example-gitlab-connection',
Expand Down
4 changes: 2 additions & 2 deletions package.json

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

11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export enum CodeConnectionsHostProviderType {
GIT_LAB_SELF_MANAGED = 'GitLabSelfManaged',
}

export enum ResponseField {
HOST_ARN = 'HostArn',
}

export interface CodeConnectionsHostCustomResourceProps {
readonly name: string;
readonly providerEndpoint: string;
Expand All @@ -25,7 +29,7 @@ export class CodeConnectionsHostCustomResource extends cr.AwsCustomResource {

// 👇 Create random 8 length string
const random: string = crypto.createHash('shake256', { outputLength: 4 })
.update(cdk.Names.uniqueId(scope))
.update(`${cdk.Names.uniqueId(scope)}.${props.name}.${props.providerEndpoint}.${props.providerType}`)
.digest('hex');

const account = cdk.Stack.of(scope).account;
Expand Down Expand Up @@ -89,4 +93,9 @@ export class CodeConnectionsHostCustomResource extends cr.AwsCustomResource {
},
});
}

findHostArn(): string {
return this.getResponseField(ResponseField.HOST_ARN);
}

}
19 changes: 16 additions & 3 deletions test/__snapshots__/custom-resource.bitbucket.test.ts.snap

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

19 changes: 16 additions & 3 deletions test/__snapshots__/custom-resource.github-enterprise.test.ts.snap

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

19 changes: 16 additions & 3 deletions test/__snapshots__/custom-resource.github.test.ts.snap

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

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

19 changes: 16 additions & 3 deletions test/__snapshots__/custom-resource.gitlab.test.ts.snap

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

8 changes: 8 additions & 0 deletions test/custom-resource.bitbucket.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import * as codeconnections from 'aws-cdk-lib/aws-codeconnections';
import { AwsCustomResource } from 'aws-cdk-lib/custom-resources';
import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src';

Expand All @@ -19,6 +20,13 @@ describe('CustomResource Testing', () => {
providerType: CodeConnectionsHostProviderType.BIT_BUCKET,
});

const hostArn = bitbucketConnectionHostCustomResource.findHostArn();

new codeconnections.CfnConnection(stack, 'Connection', {
connectionName: 'example-bitbucket-connection',
hostArn,
});

const template = Template.fromStack(stack);

it('Is Bitbucket Connection Host CustomResource', () => {
Expand Down
8 changes: 8 additions & 0 deletions test/custom-resource.github-enterprise.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import * as codeconnections from 'aws-cdk-lib/aws-codeconnections';
import { AwsCustomResource } from 'aws-cdk-lib/custom-resources';
import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src';

Expand All @@ -19,6 +20,13 @@ describe('CustomResource Testing', () => {
providerType: CodeConnectionsHostProviderType.GIT_HUB_ENTERPRISE_SERVER,
});

const hostArn = gitHubEnterpriseConnectionHostCustomResource.findHostArn();

new codeconnections.CfnConnection(stack, 'Connection', {
connectionName: 'example-github-enterprise-connection',
hostArn,
});

const template = Template.fromStack(stack);

it('Is GitHub Enterprise Connection Host CustomResource', () => {
Expand Down
8 changes: 8 additions & 0 deletions test/custom-resource.github.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { App, Stack } from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import * as codeconnections from 'aws-cdk-lib/aws-codeconnections';
import { AwsCustomResource } from 'aws-cdk-lib/custom-resources';
import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src';

Expand All @@ -19,6 +20,13 @@ describe('CustomResource Testing', () => {
providerType: CodeConnectionsHostProviderType.GIT_HUB,
});

const hostArn = gitHubConnectionHostCustomResource.findHostArn();

new codeconnections.CfnConnection(stack, 'Connection', {
connectionName: 'example-github-connection',
hostArn,
});

const template = Template.fromStack(stack);

it('Is GitHub Connection Host CustomResource', () => {
Expand Down
Loading