Skip to content
v2.273.0

Experimental

@aws-cdk/aws-cloud9-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

Ec2Environment L2 construct ​

A Cloud9 Environment with Amazon EC2.

Example ​

ts
import * as iam from 'aws-cdk-lib/aws-iam';

const user = new iam.User(this, 'user');
user.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('AWSCloud9Administrator'));
declare const vpc: ec2.Vpc;
new cloud9.Ec2Environment(this, 'C9Env', {
  vpc,
  imageId: cloud9.ImageId.AMAZON_LINUX_2,

  owner: cloud9.Owner.user(user)
})
python
import aws_cdk.aws_iam as iam
# vpc: ec2.Vpc


user = iam.User(self, "user")
user.add_managed_policy(iam.ManagedPolicy.from_aws_managed_policy_name("AWSCloud9Administrator"))
cloud9.Ec2Environment(self, "C9Env",
    vpc=vpc,
    image_id=cloud9.ImageId.AMAZON_LINUX_2,

    owner=cloud9.Owner.user(user)
)
java
import software.amazon.awscdk.services.iam.*;
Vpc vpc;


User user = new User(this, "user");
user.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName("AWSCloud9Administrator"));
Ec2Environment.Builder.create(this, "C9Env")
        .vpc(vpc)
        .imageId(ImageId.AMAZON_LINUX_2)

        .owner(Owner.user(user))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Cloud9.Alpha
using Amazon.CDK.AWS.IAM;
Vpc vpc;


var user = new User(this, "user");
user.AddManagedPolicy(ManagedPolicy.FromAwsManagedPolicyName("AWSCloud9Administrator"));
new Ec2Environment(this, "C9Env", new Ec2EnvironmentProps {
    Vpc = vpc,
    ImageId = ImageId.AMAZON_LINUX_2,

    Owner = Owner.User(user)
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdkcloud9alpha/v2
import "github.com/aws/aws-cdk-go/awscdk"
var vpc Vpc


user := iam.NewUser(this, jsii.String("user"))
user.AddManagedPolicy(iam.ManagedPolicy_FromAwsManagedPolicyName(jsii.String("AWSCloud9Administrator")))
cloud9.NewEc2Environment(this, jsii.String("C9Env"), &Ec2EnvironmentProps{
	Vpc: Vpc,
	ImageId: cloud9.ImageId_AMAZON_LINUX_2,

	Owner: cloud9.Owner_User(user),
})

Initializer ​

ts
new Ec2Environment(scope: Construct, id: string, props: Ec2EnvironmentProps)
python
Ec2Environment(scope: Construct, id: str, props: Ec2EnvironmentProps)
java
new Ec2Environment(Construct scope, String id, Ec2EnvironmentProps props)
csharp
new Ec2Environment(Construct scope, string id, Ec2EnvironmentProps props)
go
NewEc2Environment(Scope Construct, Id *string, Props Ec2EnvironmentProps)

Construct Props ​

automaticStopDurationautomatic_stopDurationautomaticStopDurationAutomaticStopDurationAutomaticStopDuration= The instance will not be shut do…#
The number of minutes until the running instance is shut down after the environment was last used.

Setting a value of 0 means the instance will never be automatically shut down."

default

Default: The instance will not be shut down automatically.

clonedRepositoriesCloneRepository[]cloned_repositoriestyping.List[CloneRepository]clonedRepositoriesList<CloneRepository>ClonedRepositoriesCloneRepository[]ClonedRepositories*[]CloneRepository= do not clone any repository#
The AWS CodeCommit repository to be cloned.
connectionTypeConnectionTypeconnection_typeConnectionTypeconnectionTypeConnectionTypeConnectionTypeConnectionTypeConnectionTypeConnectionType= CONNECT_SSH#
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)

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*string= no description#
Description of the environment.
ec2EnvironmentNamestringec2_environment_namestrec2EnvironmentNameStringEc2EnvironmentNamestringEc2EnvironmentName*string= automatically generated name#
Name of the environment.
imageIdImageIdimage_idImageIdimageIdImageIdImageIdImageIdImageIdImageIdrequired#
The image ID used for creating an Amazon EC2 environment.
instanceTypeInstanceTypeinstance_typeInstanceTypeinstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceType= t2.micro#
The type of instance to connect to the environment.
ownerOwnerownerOwnerownerOwnerOwnerOwnerOwnerOwner= The identity that CloudFormation…#
Owner of the environment.

The owner has full control of the environment and can invite additional members.

default

Default: The identity that CloudFormation executes under will be the owner

subnetSelectionSubnetSelectionsubnet_selectionSubnetSelectionsubnetSelectionSubnetSelectionSubnetSelectionSubnetSelectionSubnetSelectionSubnetSelection= all public subnets of the VPC ar…#
The subnetSelection of the VPC that AWS Cloud9 will use to communicate with the Amazon EC2 instance.
default

Default: all public subnets of the VPC are selected.

vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
The VPC that AWS Cloud9 will use to communicate with the Amazon Elastic Compute Cloud (Amazon EC2) instance.

Properties ​

ec2EnvironmentArnstringec2_environment_arnstrec2EnvironmentArnStringEc2EnvironmentArnstringEc2EnvironmentArn*stringrequired#
The environment ARN of this Cloud9 environment.
ec2EnvironmentNamestringec2_environment_namestrec2EnvironmentNameStringEc2EnvironmentNamestringEc2EnvironmentName*stringrequired#
The environment name of this Cloud9 environment.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

environmentIdstringenvironment_idstrenvironmentIdStringEnvironmentIdstringEnvironmentId*stringrequired#
The environment ID of this Cloud9 environment.
ideUrlstringide_urlstrideUrlStringIdeUrlstringIdeUrl*stringrequired#
The complete IDE URL of this Cloud9 environment.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
VPC ID.

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

fromEc2EnvironmentName(scope: Construct, id: string, ec2EnvironmentName: string): IEc2Environment@staticmethod def from_ec2_environment_name(scope: Construct, id: str, ec2_environment_name: str) -> IEc2Environmentpublic static IEc2Environment fromEc2EnvironmentName(Construct scope, String id, String ec2EnvironmentName)public static IEc2Environment FromEc2EnvironmentName(Construct scope, string id, string ec2EnvironmentName)func FromEc2EnvironmentName(Scope Construct, Id *string, Ec2EnvironmentName *string) IEc2Environmentstatic#
import from EnvironmentEc2Name.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.