software.amazon.awscdk.services.cloud9.alpha.package-info Maven / Gradle / Ivy
Show all versions of cloud9-alpha Show documentation
/**
* AWS Cloud9 Construct Library
*
* ---
*
*
*
*
*
* The APIs of higher level constructs in this module are experimental and under active development.
* They are subject to non-backward compatible changes or removal in any future version. These are
* not subject to the Semantic Versioning model and breaking changes will be
* announced in the release notes. 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.
*
*
*
*
*
*
*
* This module is part of the AWS Cloud Development Kit project.
*
* AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a
* browser. It includes a code editor, debugger, and terminal. Cloud9 comes prepackaged with essential tools for popular
* programming languages, including JavaScript, Python, PHP, and more, so you don’t need to install files or configure your
* development machine to start new projects. Since your Cloud9 IDE is cloud-based, you can work on your projects from your
* office, home, or anywhere using an internet-connected machine. Cloud9 also provides a seamless experience for developing
* serverless applications enabling you to easily define resources, debug, and switch between local and remote execution of
* serverless applications. With Cloud9, you can quickly share your development environment with your team, enabling you to pair
* program and track each other's inputs in real time.
*
*
Creating EC2 Environment
*
* EC2 Environments are defined with Ec2Environment
. To create an EC2 environment in the private subnet, specify
* subnetSelection
with private subnetType
.
*
*
* // create a cloud9 ec2 environment in a new VPC
* Vpc vpc = Vpc.Builder.create(this, "VPC").maxAzs(3).build();
* Ec2Environment.Builder.create(this, "Cloud9Env").vpc(vpc).imageId(ImageId.AMAZON_LINUX_2).build();
*
* // or create the cloud9 environment in the default VPC with specific instanceType
* IVpc defaultVpc = Vpc.fromLookup(this, "DefaultVPC", VpcLookupOptions.builder().isDefault(true).build());
* Ec2Environment.Builder.create(this, "Cloud9Env2")
* .vpc(defaultVpc)
* .instanceType(new InstanceType("t3.large"))
* .imageId(ImageId.AMAZON_LINUX_2)
* .build();
*
* // or specify in a different subnetSelection
* Ec2Environment c9env = Ec2Environment.Builder.create(this, "Cloud9Env3")
* .vpc(vpc)
* .subnetSelection(SubnetSelection.builder()
* .subnetType(SubnetType.PRIVATE_WITH_EGRESS)
* .build())
* .imageId(ImageId.AMAZON_LINUX_2)
* .build();
*
* // print the Cloud9 IDE URL in the output
* // print the Cloud9 IDE URL in the output
* CfnOutput.Builder.create(this, "URL").value(c9env.getIdeUrl()).build();
*
*
*
Specifying EC2 AMI
*
* Use imageId
to specify the EC2 AMI image to be used:
*
*
* IVpc defaultVpc = Vpc.fromLookup(this, "DefaultVPC", VpcLookupOptions.builder().isDefault(true).build());
* Ec2Environment.Builder.create(this, "Cloud9Env2")
* .vpc(defaultVpc)
* .instanceType(new InstanceType("t3.large"))
* .imageId(ImageId.UBUNTU_18_04)
* .build();
*
*
*
Cloning Repositories
*
* Use clonedRepositories
to clone one or multiple AWS Codecommit repositories into the environment:
*
*
* import software.amazon.awscdk.services.codecommit.*;
*
* // create a new Cloud9 environment and clone the two repositories
* Vpc vpc;
*
*
* // create a codecommit repository to clone into the cloud9 environment
* Repository repoNew = Repository.Builder.create(this, "RepoNew")
* .repositoryName("new-repo")
* .build();
*
* // import an existing codecommit repository to clone into the cloud9 environment
* IRepository repoExisting = Repository.fromRepositoryName(this, "RepoExisting", "existing-repo");
* Ec2Environment.Builder.create(this, "C9Env")
* .vpc(vpc)
* .clonedRepositories(List.of(CloneRepository.fromCodeCommit(repoNew, "/src/new-repo"), CloneRepository.fromCodeCommit(repoExisting, "/src/existing-repo")))
* .imageId(ImageId.AMAZON_LINUX_2)
* .build();
*
*
*
Specifying Owners
*
* Every Cloud9 Environment has an owner. An owner has full control over the environment, and can invite additional members to the environment for collaboration purposes. For more information, see Working with shared environments in AWS Cloud9).
*
* By default, the owner will be the identity that creates the Environment, which is most likely your CloudFormation Execution Role when the Environment is created using CloudFormation. Provider a value for the owner
property to assign a different owner, either a specific IAM User or the AWS Account Root User.
*
* Owner
is an IAM entity that owns a Cloud9 environment. Owner
has their own access permissions, and resources. You can specify an Owner
in an EC2 environment which could be of the following types:
*
*
* - Account Root
* - IAM User
* - IAM Federated User
* - IAM Assumed Role
*
*
* The ARN of the owner must satisfy the following regular expression: ^arn:(aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):(iam|sts)::\d+:(root|(user\/[\w+=/:,.@-]{1,64}|federated-user\/[\w+=/:,.@-]{2,32}|assumed-role\/[\w+=:,.@-]{1,64}\/[\w+=,.@-]{1,64}))$
*
* Note: Using the account root user is not recommended, see environment sharing best practices.
*
* To specify the AWS Account Root User as the environment owner, use Owner.accountRoot()
*
*
* Vpc vpc;
*
* Ec2Environment.Builder.create(this, "C9Env")
* .vpc(vpc)
* .imageId(ImageId.AMAZON_LINUX_2)
* .owner(Owner.accountRoot("111111111"))
* .build();
*
*
* To specify a specific IAM User as the environment owner, use Owner.user()
. The user should have the AWSCloud9Administrator
managed policy
*
* The user should have the AWSCloud9User
(preferred) or AWSCloud9Administrator
managed policy attached.
*
*
* 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();
*
*
* To specify a specific IAM Federated User as the environment owner, use Owner.federatedUser(accountId, userName)
.
*
* The user should have the AWSCloud9User
(preferred) or AWSCloud9Administrator
managed policy attached.
*
*
* import software.amazon.awscdk.services.iam.*;
*
* Vpc vpc;
*
* Ec2Environment.Builder.create(this, "C9Env")
* .vpc(vpc)
* .imageId(ImageId.AMAZON_LINUX_2)
* .owner(Owner.federatedUser(Stack.of(this).getAccount(), "Admin/johndoe"))
* .build();
*
*
* To specify an IAM Assumed Role as the environment owner, use Owner.assumedRole(accountId: string, roleName: string)
.
*
* The role should have the AWSCloud9User
(preferred) or AWSCloud9Administrator
managed policy attached.
*
*
* import software.amazon.awscdk.services.iam.*;
*
* Vpc vpc;
*
* Ec2Environment.Builder.create(this, "C9Env")
* .vpc(vpc)
* .imageId(ImageId.AMAZON_LINUX_2)
* .owner(Owner.assumedRole(Stack.of(this).getAccount(), "Admin/johndoe-role"))
* .build();
*
*
*
Auto-Hibernation
*
* A Cloud9 environment can automatically start and stop the associated EC2 instance to reduce costs.
*
* Use automaticStop
to specify the number of minutes until the running instance is shut down after the environment was last used.
*
*
* IVpc defaultVpc = Vpc.fromLookup(this, "DefaultVPC", VpcLookupOptions.builder().isDefault(true).build());
* Ec2Environment.Builder.create(this, "Cloud9Env2")
* .vpc(defaultVpc)
* .imageId(ImageId.AMAZON_LINUX_2)
* .automaticStop(Duration.minutes(30))
* .build();
*
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
package software.amazon.awscdk.services.cloud9.alpha;