AWS Cloud9 Construct Library¶---
All classes with the
Cfnprefix in this module (CFN Resources) are always stable and safe to use.
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.
Creating EC2 Environment¶
EC2 Environments are defined with
Ec2Environment. To create an EC2 environment in the private subnet, specify
subnetSelection with private
# Example automatically generated from non-compiling source. May contain errors. from aws_cdk.aws_ec2 import SubnetSelection import aws_cdk.aws_cloud9 as cloud9 # create a cloud9 ec2 environment in a new VPC vpc = ec2.Vpc(self, "VPC", max_azs=3) cloud9.Ec2Environment(self, "Cloud9Env", vpc=vpc) # or create the cloud9 environment in the default VPC with specific instanceType default_vpc = ec2.Vpc.from_lookup(self, "DefaultVPC", is_default=True) cloud9.Ec2Environment(self, "Cloud9Env2", vpc=default_vpc, instance_type=ec2.InstanceType("t3.large") ) # or specify in a different subnetSelection c9env = cloud9.Ec2Environment(self, "Cloud9Env3", vpc=vpc, subnet_selection=SubnetSelection( subnet_type=ec2.SubnetType.PRIVATE ) ) # print the Cloud9 IDE URL in the output cdk.CfnOutput(self, "URL", value=c9env.ide_url)
clonedRepositories to clone one or multiple AWS Codecommit repositories into the environment:
# Example automatically generated from non-compiling source. May contain errors. # create a codecommit repository to clone into the cloud9 environment repo_new = codecommit.Repository(self, "RepoNew", repository_name="new-repo" ) # import an existing codecommit repository to clone into the cloud9 environment repo_existing = codecommit.Repository.from_repository_name(stack, "RepoExisting", "existing-repo") # create a new Cloud9 environment and clone the two repositories cloud9.Ec2Environment(stack, "C9Env", vpc=vpc, cloned_repositories=[ cloud9.CloneRepository.from_code_commit(repo_new, "/src/new-repo"), cloud9.CloneRepository.from_code_commit(repo_existing, "/src/existing-repo") ] )