AWS-CDK 이미지 컨테이너 생성

3510 단어 nodepythonawscdk
⚛️ 📄 🚀

모든 CDK 개발자는 Node.js 10.3.0 이상을 설치해야 합니다. Python과 같은 TypeScript 또는 JavaScript 이외의 언어로 작업하는 경우에도 마찬가지입니다.



중요: Node.js 버전 13.0.0~13.6.0은 AWS CDK와 호환되지 않습니다.



amazon/aws-lambda-python(또는 Python 기본 이미지)에서 AWS-CDK 이미지 컨테이너를 생성하고 nodejs 12를 설치하는 방법



이 문서의 내용


  • Dockerfile
  • Build and Test container image

  • 🚀 도커파일


  • 기본 이미지: amazon/aws-lambda-python:3.8
  • nodejs 12 및 aws-cdk 버전 1.73.0 설치
  • 일부 cdk 라이브러리를 설치합니다.

  • FROM amazon/aws-lambda-python:3.8
    
    ENV AWS_CDK_VERSION=1.73.0
    ENV AWS_DEFAULT_REGION=ap-northeast-2
    
    WORKDIR /opt/stack
    
    RUN yum -y update && \
        curl -sL https://rpm.nodesource.com/setup_12.x | bash - && \
        yum list available nodejs && \
        yum install -y python3-pip && \
        yum install -y nodejs && \
        npm install -g aws-cdk@${AWS_CDK_VERSION} && \
        pip3 install aws-cdk.aws-ec2 aws-cdk.aws-route53 aws-cdk.aws-iam aws-cdk.aws-elasticloadbalancingv2 aws-cdk.core
    
    CMD ["cdk version"]
    


    🚀 컨테이너 이미지 빌드 및 테스트




    ⚡ $ docker build -t awscdk .
    ⚡ $ docker run -d --name test -it awscdk
    30d272c6ad8abaa4162fdc090d81d0641d287f4ae161606bcc365da6ffe2284e
    ⚡ $ docker exec test cdk version
    1.73.0 (build eb6f3a9)
    ⚡ $ docker exec test node --version
    v12.20.0
    ⚡ $ docker exec test npm --version
    6.14.8
    ⚡ $ docker exec test cdk init -l python
    Applying project template app for python
    
    # Welcome to your CDK Python project!
    
    This is a blank project for Python development with CDK.
    
    The `cdk.json` file tells the CDK Toolkit how to execute your app.
    
    This project is set up like a standard Python project.  The initialization
    process also creates a virtualenv within this project, stored under the `.venv`
    directory.  To create the virtualenv it assumes that there is a `python3`
    (or `python` for Windows) executable in your path with access to the `venv`
    package. If for any reason the automatic creation of the virtualenv fails,
    you can create the virtualenv manually.
    
    To manually create a virtualenv on MacOS and Linux:
    
    Enjoy!
    
    Initializing a new git repository...
    /bin/sh: git: command not found
    Unable to initialize git repository for your project.
    Please run 'python3 -m venv .venv'!
    Executing Creating virtualenv...
    ✅ All done!
    
    ⚡ $ docker exec -it test ls
    app.py  cdk.json  README.md  requirements.txt  setup.py  source.bat  stack
    
    ⚡ $ docker exec -it test ls stack
    __init__.py  stack_stack.py
    


    거울:
  • https://github.com/vumdao/docker-aws-cdk
  • https://vumdao.hashnode.dev/create-aws-cdk-image-container

  • 더 읽어보기



















  • · 편물 · · · 페이지 ·

    좋은 웹페이지 즐겨찾기