diff --git a/API.md b/API.md index 089744e..66c4e42 100644 --- a/API.md +++ b/API.md @@ -200,7 +200,7 @@ const codeConnectionsHostCustomResourceProps: CodeConnectionsHostCustomResourceP | --- | --- | --- | | name | string | *No description.* | | providerEndpoint | string | *No description.* | -| providerType | string | *No description.* | +| providerType | CodeConnectionsHostProviderType | *No description.* | --- @@ -227,12 +227,52 @@ public readonly providerEndpoint: string; ##### `providerType`Required ```typescript -public readonly providerType: string; +public readonly providerType: CodeConnectionsHostProviderType; ``` -- *Type:* string +- *Type:* CodeConnectionsHostProviderType + +--- + + + +## Enums + +### CodeConnectionsHostProviderType + +#### Members + +| **Name** | **Description** | +| --- | --- | +| BIT_BUCKET | *No description.* | +| GIT_HUB | *No description.* | +| GIT_HUB_ENTERPRISE_SERVER | *No description.* | +| GIT_LAB | *No description.* | +| GIT_LAB_SELF_MANAGED | *No description.* | + +--- + +##### `BIT_BUCKET` --- +##### `GIT_HUB` + +--- + + +##### `GIT_HUB_ENTERPRISE_SERVER` + +--- + + +##### `GIT_LAB` + +--- + + +##### `GIT_LAB_SELF_MANAGED` + +--- diff --git a/README.md b/README.md index 098c909..6532114 100644 --- a/README.md +++ b/README.md @@ -28,12 +28,12 @@ yarn add @gammarers/aws-codeconnections-host-custom-resource ## Example ```typescript -import { RDSDatabaseAutoRunningStopStack } from '@gammarers/aws-codeconnections-host-custom-resource'; +import { RDSDatabaseAutoRunningStopStack, CodeConnectionsHostProviderType } from '@gammarers/aws-codeconnections-host-custom-resource'; const codeConnectionsHostCustomResource = new CodeConnectionsHostCustomResource(this, 'CodeConnectionsHost', { name: 'gitlab.example.com', // required, connection host name (Minimum length of 1. Maximum length of 64.) providerEndpoint: 'https://gitlab.example.com', // required, your provider endpoint (Minimum length of 1. Maximum length of 512.) - providerType: 'GitLabSelfManaged', // required, Bitbucket | GitHub | GitHubEnterpriseServer | GitLab | GitLabSelfManaged + providerType: CodeConnectionsHostProviderType.GIT_LAB_SELF_MANAGED, }); // get host arn diff --git a/src/index.ts b/src/index.ts index 85cd3b9..b5a0410 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,10 +4,19 @@ import * as iam from 'aws-cdk-lib/aws-iam'; import * as cr from 'aws-cdk-lib/custom-resources'; import { Construct } from 'constructs'; +// Bitbucket | GitHub | GitHubEnterpriseServer | GitLab | GitLabSelfManaged +export enum CodeConnectionsHostProviderType { + BIT_BUCKET = 'Bitbucket', + GIT_HUB = 'GitHub', + GIT_HUB_ENTERPRISE_SERVER = 'GitHubEnterpriseServer', + GIT_LAB = 'GitLab', + GIT_LAB_SELF_MANAGED = 'GitLabSelfManaged', +} + export interface CodeConnectionsHostCustomResourceProps { readonly name: string; readonly providerEndpoint: string; - readonly providerType: string; + readonly providerType: CodeConnectionsHostProviderType; } export class CodeConnectionsHostCustomResource extends cr.AwsCustomResource { diff --git a/test/__snapshots__/custom-resource.bitbucket.test.ts.snap b/test/__snapshots__/custom-resource.bitbucket.test.ts.snap new file mode 100644 index 0000000..f4af77d --- /dev/null +++ b/test/__snapshots__/custom-resource.bitbucket.test.ts.snap @@ -0,0 +1,133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CustomResource Testing Should match snapshot 1`] = ` +{ + "Parameters": { + "BootstrapVersion": { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": { + "AWS679f53fac002430cb0da5b7982bd22872D164C4C": { + "DependsOn": [ + "FunctionRole111A5701", + ], + "Properties": { + "Code": { + "S3Bucket": "cdk-hnb659fds-assets-123456789012-us-east-1", + "S3Key": "17c16a3854838fd3ff4bda08146122a6701f33b9c86ae17f415ad0dc47a97544.zip", + }, + "FunctionName": "custom-resource-codeconnection-host-eadb0d58-func", + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "FunctionRole111A5701", + "Arn", + ], + }, + "Runtime": "nodejs18.x", + "Timeout": 15, + }, + "Type": "AWS::Lambda::Function", + }, + "BitBucketCodeConnectionsHostCustomResource983A9F6A": { + "DeletionPolicy": "Delete", + "Properties": { + "Create": "{"service":"CodeConnections","action":"createHost","parameters":{"Name":"bitbucket.example.com","ProviderEndpoint":"https://bitbucket.example.com","ProviderType":"Bitbucket"},"physicalResourceId":{"responsePath":"HostArn"}}", + "Delete": "{"service":"CodeConnections","action":"deleteHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:"}}", + "InstallLatestAwsSdk": true, + "ServiceToken": { + "Fn::GetAtt": [ + "AWS679f53fac002430cb0da5b7982bd22872D164C4C", + "Arn", + ], + }, + "Update": "{"service":"CodeConnections","action":"updateHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:","ProviderEndpoint":"https://bitbucket.example.com"}}", + }, + "Type": "Custom::AWS", + "UpdateReplacePolicy": "Delete", + }, + "FunctionRole111A5701": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "Description": "Custom Resource Function Execution Role.", + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + ], + ], + }, + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "codeconnections:CreateHost", + "codeconnections:UpdateHost", + "codeconnections:DeleteHost", + ], + "Effect": "Allow", + "Resource": "arn:aws:codeconnections:us-east-1:123456789012:*", + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "CustomResourcePolicy", + }, + ], + "RoleName": "custom-resource-codeconnection-host-eadb0d58-func-exc-role", + }, + "Type": "AWS::IAM::Role", + }, + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5", + ], + { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; diff --git a/test/__snapshots__/custom-resource.github-enterprise.test.ts.snap b/test/__snapshots__/custom-resource.github-enterprise.test.ts.snap new file mode 100644 index 0000000..872a446 --- /dev/null +++ b/test/__snapshots__/custom-resource.github-enterprise.test.ts.snap @@ -0,0 +1,133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CustomResource Testing Should match snapshot 1`] = ` +{ + "Parameters": { + "BootstrapVersion": { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": { + "AWS679f53fac002430cb0da5b7982bd22872D164C4C": { + "DependsOn": [ + "FunctionRole111A5701", + ], + "Properties": { + "Code": { + "S3Bucket": "cdk-hnb659fds-assets-123456789012-us-east-1", + "S3Key": "17c16a3854838fd3ff4bda08146122a6701f33b9c86ae17f415ad0dc47a97544.zip", + }, + "FunctionName": "custom-resource-codeconnection-host-eadb0d58-func", + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "FunctionRole111A5701", + "Arn", + ], + }, + "Runtime": "nodejs18.x", + "Timeout": 15, + }, + "Type": "AWS::Lambda::Function", + }, + "FunctionRole111A5701": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "Description": "Custom Resource Function Execution Role.", + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + ], + ], + }, + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "codeconnections:CreateHost", + "codeconnections:UpdateHost", + "codeconnections:DeleteHost", + ], + "Effect": "Allow", + "Resource": "arn:aws:codeconnections:us-east-1:123456789012:*", + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "CustomResourcePolicy", + }, + ], + "RoleName": "custom-resource-codeconnection-host-eadb0d58-func-exc-role", + }, + "Type": "AWS::IAM::Role", + }, + "GitHibEnterpriseCodeConnectionsHostCustomResource3C231391": { + "DeletionPolicy": "Delete", + "Properties": { + "Create": "{"service":"CodeConnections","action":"createHost","parameters":{"Name":"github.example.com","ProviderEndpoint":"https://github.example.com","ProviderType":"GitHubEnterpriseServer"},"physicalResourceId":{"responsePath":"HostArn"}}", + "Delete": "{"service":"CodeConnections","action":"deleteHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:"}}", + "InstallLatestAwsSdk": true, + "ServiceToken": { + "Fn::GetAtt": [ + "AWS679f53fac002430cb0da5b7982bd22872D164C4C", + "Arn", + ], + }, + "Update": "{"service":"CodeConnections","action":"updateHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:","ProviderEndpoint":"https://github.example.com"}}", + }, + "Type": "Custom::AWS", + "UpdateReplacePolicy": "Delete", + }, + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5", + ], + { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; diff --git a/test/__snapshots__/custom-resource.github.test.ts.snap b/test/__snapshots__/custom-resource.github.test.ts.snap new file mode 100644 index 0000000..cc665e2 --- /dev/null +++ b/test/__snapshots__/custom-resource.github.test.ts.snap @@ -0,0 +1,133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CustomResource Testing Should match snapshot 1`] = ` +{ + "Parameters": { + "BootstrapVersion": { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": { + "AWS679f53fac002430cb0da5b7982bd22872D164C4C": { + "DependsOn": [ + "FunctionRole111A5701", + ], + "Properties": { + "Code": { + "S3Bucket": "cdk-hnb659fds-assets-123456789012-us-east-1", + "S3Key": "17c16a3854838fd3ff4bda08146122a6701f33b9c86ae17f415ad0dc47a97544.zip", + }, + "FunctionName": "custom-resource-codeconnection-host-eadb0d58-func", + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "FunctionRole111A5701", + "Arn", + ], + }, + "Runtime": "nodejs18.x", + "Timeout": 15, + }, + "Type": "AWS::Lambda::Function", + }, + "FunctionRole111A5701": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "Description": "Custom Resource Function Execution Role.", + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + ], + ], + }, + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "codeconnections:CreateHost", + "codeconnections:UpdateHost", + "codeconnections:DeleteHost", + ], + "Effect": "Allow", + "Resource": "arn:aws:codeconnections:us-east-1:123456789012:*", + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "CustomResourcePolicy", + }, + ], + "RoleName": "custom-resource-codeconnection-host-eadb0d58-func-exc-role", + }, + "Type": "AWS::IAM::Role", + }, + "GitHubCodeConnectionsHostCustomResource79EB46DC": { + "DeletionPolicy": "Delete", + "Properties": { + "Create": "{"service":"CodeConnections","action":"createHost","parameters":{"Name":"github.example.com","ProviderEndpoint":"https://github.example.com","ProviderType":"GitHub"},"physicalResourceId":{"responsePath":"HostArn"}}", + "Delete": "{"service":"CodeConnections","action":"deleteHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:"}}", + "InstallLatestAwsSdk": true, + "ServiceToken": { + "Fn::GetAtt": [ + "AWS679f53fac002430cb0da5b7982bd22872D164C4C", + "Arn", + ], + }, + "Update": "{"service":"CodeConnections","action":"updateHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:","ProviderEndpoint":"https://github.example.com"}}", + }, + "Type": "Custom::AWS", + "UpdateReplacePolicy": "Delete", + }, + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5", + ], + { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; diff --git a/test/__snapshots__/custom-resource.test.ts.snap b/test/__snapshots__/custom-resource.gitlab-self-managed.test.ts.snap similarity index 98% rename from test/__snapshots__/custom-resource.test.ts.snap rename to test/__snapshots__/custom-resource.gitlab-self-managed.test.ts.snap index 3e4bf05..d68e113 100644 --- a/test/__snapshots__/custom-resource.test.ts.snap +++ b/test/__snapshots__/custom-resource.gitlab-self-managed.test.ts.snap @@ -32,23 +32,6 @@ exports[`CustomResource Testing Should match snapshot 1`] = ` }, "Type": "AWS::Lambda::Function", }, - "CodeConnectionsHostCustomResourceA0D203C1": { - "DeletionPolicy": "Delete", - "Properties": { - "Create": "{"service":"CodeConnections","action":"createHost","parameters":{"Name":"gitlab.example.com","ProviderEndpoint":"https://gitlab.example.com","ProviderType":"GitLabSelfManaged"},"physicalResourceId":{"responsePath":"HostArn"}}", - "Delete": "{"service":"CodeConnections","action":"deleteHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:"}}", - "InstallLatestAwsSdk": true, - "ServiceToken": { - "Fn::GetAtt": [ - "AWS679f53fac002430cb0da5b7982bd22872D164C4C", - "Arn", - ], - }, - "Update": "{"service":"CodeConnections","action":"updateHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:","ProviderEndpoint":"https://gitlab.example.com"}}", - }, - "Type": "Custom::AWS", - "UpdateReplacePolicy": "Delete", - }, "FunctionRole111A5701": { "Properties": { "AssumeRolePolicyDocument": { @@ -101,6 +84,23 @@ exports[`CustomResource Testing Should match snapshot 1`] = ` }, "Type": "AWS::IAM::Role", }, + "GitLabSelfManagedCodeConnectionsHostCustomResource31CD67FB": { + "DeletionPolicy": "Delete", + "Properties": { + "Create": "{"service":"CodeConnections","action":"createHost","parameters":{"Name":"gitlab.example.com","ProviderEndpoint":"https://gitlab.example.com","ProviderType":"GitLabSelfManaged"},"physicalResourceId":{"responsePath":"HostArn"}}", + "Delete": "{"service":"CodeConnections","action":"deleteHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:"}}", + "InstallLatestAwsSdk": true, + "ServiceToken": { + "Fn::GetAtt": [ + "AWS679f53fac002430cb0da5b7982bd22872D164C4C", + "Arn", + ], + }, + "Update": "{"service":"CodeConnections","action":"updateHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:","ProviderEndpoint":"https://gitlab.example.com"}}", + }, + "Type": "Custom::AWS", + "UpdateReplacePolicy": "Delete", + }, }, "Rules": { "CheckBootstrapVersion": { diff --git a/test/__snapshots__/custom-resource.gitlab.test.ts.snap b/test/__snapshots__/custom-resource.gitlab.test.ts.snap new file mode 100644 index 0000000..e5f5548 --- /dev/null +++ b/test/__snapshots__/custom-resource.gitlab.test.ts.snap @@ -0,0 +1,133 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CustomResource Testing Should match snapshot 1`] = ` +{ + "Parameters": { + "BootstrapVersion": { + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]", + "Type": "AWS::SSM::Parameter::Value", + }, + }, + "Resources": { + "AWS679f53fac002430cb0da5b7982bd22872D164C4C": { + "DependsOn": [ + "FunctionRole111A5701", + ], + "Properties": { + "Code": { + "S3Bucket": "cdk-hnb659fds-assets-123456789012-us-east-1", + "S3Key": "17c16a3854838fd3ff4bda08146122a6701f33b9c86ae17f415ad0dc47a97544.zip", + }, + "FunctionName": "custom-resource-codeconnection-host-eadb0d58-func", + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "FunctionRole111A5701", + "Arn", + ], + }, + "Runtime": "nodejs18.x", + "Timeout": 15, + }, + "Type": "AWS::Lambda::Function", + }, + "FunctionRole111A5701": { + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com", + }, + }, + ], + "Version": "2012-10-17", + }, + "Description": "Custom Resource Function Execution Role.", + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition", + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + ], + ], + }, + ], + "Policies": [ + { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "codeconnections:CreateHost", + "codeconnections:UpdateHost", + "codeconnections:DeleteHost", + ], + "Effect": "Allow", + "Resource": "arn:aws:codeconnections:us-east-1:123456789012:*", + }, + ], + "Version": "2012-10-17", + }, + "PolicyName": "CustomResourcePolicy", + }, + ], + "RoleName": "custom-resource-codeconnection-host-eadb0d58-func-exc-role", + }, + "Type": "AWS::IAM::Role", + }, + "GitLabCodeConnectionsHostCustomResource84EEAEED": { + "DeletionPolicy": "Delete", + "Properties": { + "Create": "{"service":"CodeConnections","action":"createHost","parameters":{"Name":"gitlab.example.com","ProviderEndpoint":"https://gitlab.example.com","ProviderType":"GitLab"},"physicalResourceId":{"responsePath":"HostArn"}}", + "Delete": "{"service":"CodeConnections","action":"deleteHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:"}}", + "InstallLatestAwsSdk": true, + "ServiceToken": { + "Fn::GetAtt": [ + "AWS679f53fac002430cb0da5b7982bd22872D164C4C", + "Arn", + ], + }, + "Update": "{"service":"CodeConnections","action":"updateHost","parameters":{"HostArn":"PHYSICAL:RESOURCEID:","ProviderEndpoint":"https://gitlab.example.com"}}", + }, + "Type": "Custom::AWS", + "UpdateReplacePolicy": "Delete", + }, + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5", + ], + { + "Ref": "BootstrapVersion", + }, + ], + }, + ], + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.", + }, + ], + }, + }, +} +`; diff --git a/test/custom-resource.bitbucket.test.ts b/test/custom-resource.bitbucket.test.ts new file mode 100644 index 0000000..aaf79bb --- /dev/null +++ b/test/custom-resource.bitbucket.test.ts @@ -0,0 +1,32 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { Template } from 'aws-cdk-lib/assertions'; +import { AwsCustomResource } from 'aws-cdk-lib/custom-resources'; +import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src'; + +describe('CustomResource Testing', () => { + + const app = new App(); + const stack = new Stack(app, 'TestingStack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const bitbucketConnectionHostCustomResource = new CodeConnectionsHostCustomResource(stack, 'BitBucketCodeConnectionsHostCustomResource', { + name: 'bitbucket.example.com', + providerEndpoint: 'https://bitbucket.example.com', + providerType: CodeConnectionsHostProviderType.BIT_BUCKET, + }); + + const template = Template.fromStack(stack); + + it('Is Bitbucket Connection Host CustomResource', () => { + expect(bitbucketConnectionHostCustomResource).toBeInstanceOf(AwsCustomResource); + }); + + it('Should match snapshot', () => { + expect(template.toJSON()).toMatchSnapshot(); + }); + +}); diff --git a/test/custom-resource.github-enterprise.test.ts b/test/custom-resource.github-enterprise.test.ts new file mode 100644 index 0000000..8e269d4 --- /dev/null +++ b/test/custom-resource.github-enterprise.test.ts @@ -0,0 +1,32 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { Template } from 'aws-cdk-lib/assertions'; +import { AwsCustomResource } from 'aws-cdk-lib/custom-resources'; +import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src'; + +describe('CustomResource Testing', () => { + + const app = new App(); + const stack = new Stack(app, 'TestingStack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const gitHubEnterpriseConnectionHostCustomResource = new CodeConnectionsHostCustomResource(stack, 'GitHibEnterpriseCodeConnectionsHostCustomResource', { + name: 'github.example.com', + providerEndpoint: 'https://github.example.com', + providerType: CodeConnectionsHostProviderType.GIT_HUB_ENTERPRISE_SERVER, + }); + + const template = Template.fromStack(stack); + + it('Is GitHub Enterprise Connection Host CustomResource', () => { + expect(gitHubEnterpriseConnectionHostCustomResource).toBeInstanceOf(AwsCustomResource); + }); + + it('Should match snapshot', () => { + expect(template.toJSON()).toMatchSnapshot(); + }); + +}); diff --git a/test/custom-resource.github.test.ts b/test/custom-resource.github.test.ts new file mode 100644 index 0000000..6edd41c --- /dev/null +++ b/test/custom-resource.github.test.ts @@ -0,0 +1,32 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { Template } from 'aws-cdk-lib/assertions'; +import { AwsCustomResource } from 'aws-cdk-lib/custom-resources'; +import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src'; + +describe('CustomResource Testing', () => { + + const app = new App(); + const stack = new Stack(app, 'TestingStack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const gitHubConnectionHostCustomResource = new CodeConnectionsHostCustomResource(stack, 'GitHubCodeConnectionsHostCustomResource', { + name: 'github.example.com', + providerEndpoint: 'https://github.example.com', + providerType: CodeConnectionsHostProviderType.GIT_HUB, + }); + + const template = Template.fromStack(stack); + + it('Is GitHub Connection Host CustomResource', () => { + expect(gitHubConnectionHostCustomResource).toBeInstanceOf(AwsCustomResource); + }); + + it('Should match snapshot', () => { + expect(template.toJSON()).toMatchSnapshot(); + }); + +}); diff --git a/test/custom-resource.gitlab-self-managed.test.ts b/test/custom-resource.gitlab-self-managed.test.ts new file mode 100644 index 0000000..f73cb22 --- /dev/null +++ b/test/custom-resource.gitlab-self-managed.test.ts @@ -0,0 +1,32 @@ +import { App, Stack } from 'aws-cdk-lib'; +import { Template } from 'aws-cdk-lib/assertions'; +import { AwsCustomResource } from 'aws-cdk-lib/custom-resources'; +import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src'; + +describe('CustomResource Testing', () => { + + const app = new App(); + const stack = new Stack(app, 'TestingStack', { + env: { + account: '123456789012', + region: 'us-east-1', + }, + }); + + const gitLabSelfManagedConnectionHostCustomResource = new CodeConnectionsHostCustomResource(stack, 'GitLabSelfManagedCodeConnectionsHostCustomResource', { + name: 'gitlab.example.com', + providerEndpoint: 'https://gitlab.example.com', + providerType: CodeConnectionsHostProviderType.GIT_LAB_SELF_MANAGED, + }); + + const template = Template.fromStack(stack); + + it('Is GitLab Self Managed Connectrion Host CustomResource', () => { + expect(gitLabSelfManagedConnectionHostCustomResource).toBeInstanceOf(AwsCustomResource); + }); + + it('Should match snapshot', () => { + expect(template.toJSON()).toMatchSnapshot(); + }); + +}); diff --git a/test/custom-resource.test.ts b/test/custom-resource.gitlab.test.ts similarity index 58% rename from test/custom-resource.test.ts rename to test/custom-resource.gitlab.test.ts index 4c7586d..1da451c 100644 --- a/test/custom-resource.test.ts +++ b/test/custom-resource.gitlab.test.ts @@ -1,7 +1,7 @@ import { App, Stack } from 'aws-cdk-lib'; import { Template } from 'aws-cdk-lib/assertions'; import { AwsCustomResource } from 'aws-cdk-lib/custom-resources'; -import { CodeConnectionsHostCustomResource } from '../src'; +import { CodeConnectionsHostCustomResource, CodeConnectionsHostProviderType } from '../src'; describe('CustomResource Testing', () => { @@ -13,16 +13,16 @@ describe('CustomResource Testing', () => { }, }); - const cr = new CodeConnectionsHostCustomResource(stack, 'CodeConnectionsHostCustomResource', { + const gitLabConnectionHostCustomResource = new CodeConnectionsHostCustomResource(stack, 'GitLabCodeConnectionsHostCustomResource', { name: 'gitlab.example.com', providerEndpoint: 'https://gitlab.example.com', - providerType: 'GitLabSelfManaged', + providerType: CodeConnectionsHostProviderType.GIT_LAB, }); const template = Template.fromStack(stack); - it('Is CustomResource', () => { - expect(cr).toBeInstanceOf(AwsCustomResource); + it('Is GitLab Connection Host CustomResource', () => { + expect(gitLabConnectionHostCustomResource).toBeInstanceOf(AwsCustomResource); }); it('Should match snapshot', () => {