AWS CDK
CDK (Cloud Development Kit)
익숙한 프로그래밍 언어를 사용하여 AWS 클라우드 애플리케이션 리소스를 모델링 및 프로비저닝할 수 있는 오픈 소스 소프트웨어 개발 프레임워크입니다.
AWS CloudFormation을 통해 리소스를 안전하고 반복 가능한 방식으로 프로비저닝합니다.
aws-cdk 는 typescript 로 개발 되었습니다.
typescript, python, java, c# 개발언어를 지원합니다.
관련 사이트들은 아래에 있습니다.
- 공식 사이트 : https://aws.amazon.com/ko/cdk/
- cdk document : https://docs.aws.amazon.com/cdk/index.html
- cdk api document : https://docs.aws.amazon.com/cdk/api/latest/index.html
- cdk github repository : https://github.com/aws/aws-cdk
- cdk workshop : https://cdkworkshop.com/
- cdk example repository : https://github.com/aws-samples/aws-cdk-examples
- cdk toolkit 정보 : https://docs.aws.amazon.com/cdk/latest/guide/tools.html
- cdk gitter channel : https://gitter.im/awslabs/aws-cdk
Why CDK
CDK vs CloudFormation Template : "7 Lines VS 700 Lines"
준비
- 반듯이 Node.js ( >= 10.3.0 ) 가 설치되어 있어야 합니다.
- typescript 를 사용하지 않더라도 Node.js ( >= 10.3.0 ) 가 설치되어 있어야 합니다.
- AWS CDK ToolKit 은 typescript로 개발되어 node.js에서 실행되어야 하기 때문입니다.
- 개발언어는 각각 typescript ( >= 2.7 ), python ( >=3.6 ), java ( maven 3.5.4 or later and java 8 ), c# ( .NET core >= 3.0, .NET framework >= 4.6.1 or Mono >= 5.4 ) 필요합니다.
설치
아래 command로 설치해줍니다.
워크 플로우
- Create the app directory
- Initialize the app
- Add code to the app
- Compile the app
- Synthesizing an AWS CloudFormation Template
- Deploy the resources defined in the app
- Modifying the app
- Preparing for Deployment
- Deploy the resources defined in the app
- Destroying the App's Resources
Create the app directory
initialize the app
여기서는 typescript 로 진행하겠습니다.
Add code to the app
여기서는 s3 bucket 1개를 생성합니다.
프로젝트에 aws-cdk/aws-s3 패키지를 설치합니다.
lib/hello-cdk-stack.ts 파일에 s3bucket 리소스 정보를 입력해줍니다.
아래 내용 중 'MyFirstBucket' 은 Amazon S3 버킷의 실제 이름이 아닌 버킷 구성 ID 입니다.
Compile the app
Synthesizing an AWS CloudFormation Template
아래 명령으로 HelloCdkStack 에 대한 AWS CloudFomation Template 가 만들어 집니다.
아래와 같은 결과값이 출력됩니다.
Deploy the resources defined in the app
Modifying the app
아래와 같이 s3에서 aws Key Management Service (KMS)를 사용하게 변경합니다.
아래 명렁어로 컴파일 합니다.
Preparing for Deployment
앱을 배포하기 전에 배포된 앱과의 차이점을 확인할 수 있습니다.
아래와 같은 결과값이 출력됩니다.
댓글
댓글 쓰기