Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cloud9): configure Connection Type of Ec2Environment #20250

Merged
merged 3 commits into from
May 19, 2022
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
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-cloud9/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ export interface IEc2Environment extends cdk.IResource {
readonly ec2EnvironmentArn: string;
}

/**
* The connection type used for connecting to an Amazon EC2 environment.
*/
export enum ConnectionType {
/**
* Conect through SSH
*/
CONNECT_SSH = 'CONNECT_SSH',
/**
* Connect through AWS Systems Manager
*/
CONNECT_SSM = 'CONNECT_SSM'
}

/**
* Properties for Ec2Environment
*/
Expand Down Expand Up @@ -70,6 +84,15 @@ export interface Ec2EnvironmentProps {
*/
// readonly clonedRepositories?: Cloud9Repository[];
readonly clonedRepositories?: CloneRepository[];

/**
* The connection type used for connecting to an Amazon EC2 environment.
*
* Valid values are: CONNECT_SSH (default) and CONNECT_SSM (connected through AWS Systems Manager)
*
* @default - CONNECT_SSH
*/
readonly connectionType?: ConnectionType
}

/**
Expand Down Expand Up @@ -139,6 +162,7 @@ export class Ec2Environment extends cdk.Resource implements IEc2Environment {
repositoryUrl: r.repositoryUrl,
pathComponent: r.pathComponent,
})) : undefined,
connectionType: props.connectionType ?? ConnectionType.CONNECT_SSH,
});
this.environmentId = c9env.ref;
this.ec2EnvironmentArn = c9env.getAtt('Arn').toString();
Expand Down
20 changes: 19 additions & 1 deletion packages/@aws-cdk/aws-cloud9/test/cloud9.environment.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Template } from '@aws-cdk/assertions';
import { Match, Template } from '@aws-cdk/assertions';
import * as codecommit from '@aws-cdk/aws-codecommit';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as cdk from '@aws-cdk/core';
import * as cloud9 from '../lib';
import { ConnectionType } from '../lib';

let stack: cdk.Stack;
let vpc: ec2.IVpc;
Expand Down Expand Up @@ -105,3 +106,20 @@ test('can use CodeCommit repositories', () => {
],
});
});

test.each([
[ConnectionType.CONNECT_SSH, 'CONNECT_SSH'],
[ConnectionType.CONNECT_SSM, 'CONNECT_SSM'],
[undefined, 'CONNECT_SSH'],
])('has connection type property (%s)', (connectionType, expected) => {
new cloud9.Ec2Environment(stack, 'C9Env', {
vpc,
connectionType,
});

Template.fromStack(stack).hasResourceProperties('AWS::Cloud9::EnvironmentEC2', {
InstanceType: Match.anyValue(),
ConnectionType: expected,
SubnetId: Match.anyValue(),
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
"C9EnvF05FC3BE": {
"Type": "AWS::Cloud9::EnvironmentEC2",
"Properties": {
"ConnectionType": "CONNECT_SSH",
"InstanceType": "t2.micro",
"Repositories": [
{
Expand Down
Loading