Skip to content

Commit

Permalink
Merge branch 'master' into optionalMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 20, 2022
2 parents 28e7a12 + 32dfa6e commit 32d2a2d
Show file tree
Hide file tree
Showing 80 changed files with 3,100 additions and 1,070 deletions.
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

0 comments on commit 32d2a2d

Please sign in to comment.