AWS Cloud9 构造库
AWS CDK v1在2023-06-01上达到了支持结束. 此软件包不再更新,用户应该迁移到 AWS CDK v2.
关于如何移徙的更多信息,请参见: 移动到 AWS CDK v2 指南。 。 。 .
这个模块是 AWS 云开发套件 项目.
AWS Cloud9 是一个以云为基础的集成开发环境(IDE),它允许您仅用一个来写、运行和调试您的代码 浏览器. 它包括一个代码编辑器,调试器,和终端. "Cloud9"预装了流行的基本工具 编程语言, 包括 JavaScript、 Python、 PHP 等, 因此不需要安装文件或配置 开发机器以启动新项目。 由于您的 Cloud9 IDE 以云为主, 您可以从您的文档中进行您的工程 办公室 家 或任何使用互联网连接的机器的地方 Cloud9还为发展提供了无缝的经验 无服务器应用程序使您能够轻松定义资源,调试,并在本地和远程执行之间切换 无服务器应用程序。 有了Cloud9,你就可以很快地与团队分享你的开发环境,使你能够配对 程序和实时跟踪对方的投入.
创建 EC2 环境
EC2 环境定义为: Ec2Environment中创建 EC2 环境
subnetSelection 专用 subnetType。 。 。 .
// create a cloud9 ec2 environment in a new VPC
const vpc = new ec2.Vpc(this, 'VPC', { maxAzs: 3});
new cloud9.Ec2Environment(this, 'Cloud9Env', { vpc });
// or create the cloud9 environment in the default VPC with specific instanceType
const defaultVpc = ec2.Vpc.fromLookup(this, 'DefaultVPC', { isDefault: true });
new cloud9.Ec2Environment(this, 'Cloud9Env2', {
vpc: defaultVpc,
instanceType: new ec2.InstanceType('t3.large'),
});
// or specify in a different subnetSelection
const c9env = new cloud9.Ec2Environment(this, 'Cloud9Env3', {
vpc,
subnetSelection: {
subnetType: ec2.SubnetType.PRIVATE_WITH_NAT,
},
});
// print the Cloud9 IDE URL in the output
new CfnOutput(this, 'URL', { value: c9env.ideUrl });
克隆存储器
使用 clonedRepositories 以复制一个或多个 AWS 编码寄存器到环境中 :
import * as codecommit from '@aws-cdk/aws-codecommit';
// create a codecommit repository to clone into the cloud9 environment
const repoNew = new codecommit.Repository(this, 'RepoNew', {
repositoryName: 'new-repo',
});
// import an existing codecommit repository to clone into the cloud9 environment
const repoExisting = codecommit.Repository.fromRepositoryName(this, 'RepoExisting', 'existing-repo');
// create a new Cloud9 environment and clone the two repositories
declare const vpc: ec2.Vpc;
new cloud9.Ec2Environment(this, 'C9Env', {
vpc,
clonedRepositories: [
cloud9.CloneRepository.fromCodeCommit(repoNew, '/src/new-repo'),
cloud9.CloneRepository.fromCodeCommit(repoExisting, '/src/existing-repo'),
],
});