跳到正文
Skillpedia
部署与云(DevOps)40k · #7071

aws-cdk-python-setup

它能做什么

这份指南可以帮你配置电脑环境,以便使用 Python 通过 AWS CDK 构建云端项目。它会告诉你如何安装必要的工具、创建新项目,并为开始开发做好准备。

适用场景

  • ✓当你想用代码搭建云端基础设施时。
  • ✓当你已经在使用 Python,并希望管理 AWS 资源时。
  • ✓当你跟着教程配置 AWS CDK 环境时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/aws-cdk-python-setup/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/aws-cdk-python-setup/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我该如何在电脑上设置环境,用 Python 创建一个 AWS CDK 项目?”

每周 5 个新技能,1 分钟读完。

工作原理

它会先检查你是否已经安装了所需工具(Node.js、Python、AWS CLI),然后说明如何安装 AWS CDK、配置 AWS 凭证,并使用 Python 虚拟环境创建新项目。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

AWS CDK Python Setup Instructions

This skill provides setup guidance for working with AWS CDK (Cloud Development Kit) projects using Python.


Prerequisites

Before starting, ensure the following tools are installed:

  • Node.js ≥ 14.15.0 — Required for the AWS CDK CLI
  • Python ≥ 3.7 — Used for writing CDK code
  • AWS CLI — Manages credentials and resources
  • Git — Version control and project management

Installation Steps

1. Install AWS CDK CLI

npm install -g aws-cdk
cdk --version

2. Configure AWS Credentials

# Install AWS CLI (if not installed)
brew install awscli

# Configure credentials
aws configure

Enter your AWS Access Key, Secret Access Key, default region, and output format when prompted.

3. Create a New CDK Project

mkdir my-cdk-project
cd my-cdk-project
cdk init app --language python

Your project will include:

  • app.py — Main application entry point
  • my_cdk_project/ — CDK stack definitions
  • requirements.txt — Python dependencies
  • cdk.json — Configuration file

4. Set Up Python Virtual Environment

# macOS/Linux
source .venv/bin/activate

# Windows
.venv\Scripts\activate

5. Install Python Dependencies

pip install -r requirements.txt

Primary dependencies:

  • aws-cdk-lib — Core CDK constructs
  • constructs — Base construct library

Development Workflow

Synthesize CloudFormation Templates

cdk synth

Generates cdk.out/ containing CloudFormation templates.

Deploy Stacks to AWS

cdk deploy

Reviews and confirms deployment to the configured AWS account.

Bootstrap (First Deployment Only)

cdk bootstrap

Prepares environment resources like S3 buckets for asset storage.


Best Practices

  • Always activate the virtual environment before working.
  • Run cdk diff before deployment to preview changes.
  • Use development accounts for testing.
  • Follow Pythonic naming and directory conventions.
  • Keep requirements.txt pinned for consistent builds.

Troubleshooting Tips

If issues occur, check:

  • AWS credentials are correctly configured.
  • Default region is set properly.
  • Node.js and Python versions meet minimum requirements.
  • Run cdk doctor to diagnose environment issues.
常见问题

什么是 AWS CDK?

AWS CDK 是一个工具,让你可以用自己熟悉的编程语言(比如 Python)来定义云端基础设施,比如服务器和数据库。

我需要全面了解 AWS 才能使用这份指南吗?

不需要。CDK 简化了很多流程,这份指南只专注于帮你准备好开发环境。

什么是 Python 虚拟环境?

它就像是给你的 Python 项目准备的一个独立“盒子”,确保项目中使用的库不会和电脑上其他软件的安装互相干扰。

详情

作者的原始描述

Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment prerequisites, create new CDK projects, manage dependencies, and deploy to AWS.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7071
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能