Skip to main content

custom-cloud9-ssm

---

Stability: Experimental

All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


Language Package
Python Logo Python cdk_use_cases.custom_cloud9_ssm
Typescript Logo Typescript @cdk-use-cases/custom-cloud9-ssm

This pattern implements a Cloud9 EC2 environment, applying an initial configuration to the EC2 instance using an SSM Document. It includes helper methods to add steps and parameters to the SSM Document and to resize the EBS volume of the EC2 instance to a given size.

Here is a minimal deployable pattern definition in Typescript:

new CustomCloud9Ssm(stack, 'CustomCloud9Ssm');

You can view other usage examples.

Initializer

new CustomCloud9Ssm(scope: Construct, id: string, props: CustomCloud9SsmProps);

Parameters

Pattern Construct Props

Name Type Description
ssmDocumentProps? ssm.CfnDocumentProps Optional configuration for the SSM Document.
cloud9Ec2Props? cloud9.CfnEnvironmentEC2Props Optional configuration for the Cloud9 EC2 environment.

Pattern Properties

Name Type Description
ec2Role iam.Role The IAM Role that is attached to the EC2 instance launched with the Cloud9 environment to grant it permissions to execute the statements in the SSM Document.

Pattern Methods

public addDocumentSteps(steps: string): void

Description

Adds one or more steps to the content of the SSM Document.

Parameters

  • steps string: YAML formatted string containing one or more steps to be added to the mainSteps section of the SSM Document.
public addDocumentParameters(parameters: string): void

Description

Adds one or more parameters to the content of the SSM Document.

Parameters

  • parameters string: YAML formatted string containing one or more parameters to be added to the parameters section of the SSM Document.
public resizeEBSTo(size: number): void

Description

Adds a step to the SSM Document content that resizes the EBS volume of the EC2 instance. Attaches the required policies to ec2Role.

Parameters

  • size number: size in GiB to resize the EBS volume to.
public deployCDKProject(url: string, stackName: string = ''): void

Description

Adds a step to the SSM Document content that deploys a CDK project from its tar compressed version.

Parameters

  • url string: from where to download the file using the wget command
  • stackName string: name of the stack to deploy

Default settings

Out of the box implementation of the Construct without any override will set the following defaults:

Cloud9 EC2 environment

  • Creates a Cloud9 EC2 environment with:

    • T3.large instance type.
    • Image id amazonlinux-2023-x86_64.

SSM Document

  • Creates an SSM Document with:

    • A step that installs jq.
    • A step that resizes the EBS volume of the EC2 instance to 100 GiB.

Architecture

Architecture Diagram

Other usage examples

Using default configuration and adding steps

import {CustomCloud9Ssm} from '@cdk-use-cases/custom-cloud9-ssm';

// Define a step that installs boto3
const boto3Step = `
- name: InstallBoto3
  action: aws:runShellScript
  inputs:
    runCommand:
    - "#!/bin/bash"
    - sudo pip install boto3
`

// Create the custom environment
let customCloud9 = new CustomCloud9Ssm(this, 'CustomCloud9Ssm')

// Add your step to the default document configuration
customCloud9.addDocumentSteps(boto3Step)

Providing props for the SSM Document and resizing the EBS volume

import {CustomCloud9Ssm, CustomCloud9SsmProps} from '@cdk-use-cases/custom-cloud9-ssm';
const yaml = require('yaml')

// Define the content of the document
const content = `
schemaVersion: '2.2'
description: Bootstrap Cloud9 EC2 instance
mainSteps:
- name: InstallBoto3
  action: aws:runShellScript
  inputs:
    runCommand:
    - "#!/bin/bash"
    - sudo pip install boto3
`

// Specify the configuration for the SSM Document
const cloud9Props: CustomCloud9SsmProps = {
    ssmDocumentProps: {
        documentType: 'Command',
        content: yaml.parse(content),
        name: 'MyDocument'
    }
}

// Create the custom environment
let customCloud9 = new CustomCloud9Ssm(this, 'CustomCloud9Ssm', cloud9Props)

// Add a step to resize the EBS volume to 50GB
customCloud9.resizeEBSTo(50)

© Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Metadata

Release files for cdk-use-cases.custom-cloud9-ssm 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cdk-use-cases.custom-cloud9-ssm 1.4.0
File Size Uploaded
cdk-use-cases.custom-cloud9-ssm-1.4.0.tar.gz 290.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cdk-use-cases.custom-cloud9-ssm 1.4.0
File Interpreter ABI Platform
cdk_use_cases.custom_cloud9_ssm-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 579.9 kB

Release files / cdk-use-cases.custom-cloud9-ssm-1.4.0.tar.gz

Download URL cdk-use-cases.custom-cloud9-ssm-1.4.0.tar.gz
Size 290.5 kB
Tags Source
SHA-256 checksum
How to use checksums
eccf1cae16f6aa053e0fc409bf2915268c522aaabbeebcb6e644ebd9eb70e2fc
BLAKE2b-256 checksum
How to use checksums
de8fca6adc0217436eaa3dd32746021a4e58fc36a4c4e59ad118b46356d72d8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.6

Release files / cdk_use_cases.custom_cloud9_ssm-1.4.0-py3-none-any.whl

Download URL cdk_use_cases.custom_cloud9_ssm-1.4.0-py3-none-any.whl
Size 289.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e357dcb22f35048cc29fd982287d6f78a650f22e601a9df7145a8a12308ed41
BLAKE2b-256 checksum
How to use checksums
7209d978d179843911ee66d67c40a1b8690b63f0e0d4db5e67abc671db27054f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.6

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.0

1 release file

1.2.0

3 release files

1.1.2

2 release files

1.0.5

2 release files

1.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page