繁体   English   中英

CircleCI 上的 AWS RDS 白名单

[英]whitelist AWS RDS on CircleCI

在合并到主服务器之前,我有一个 circleCI 配置来运行我的测试,我启动我的服务器来做我的测试,我应该连接到我的 RDS 数据库及其受安全组的保护我试图将 circleci ip 列入白名单以允许这种情况发生但是没有运气

version: 2.1

orbs:
  aws-white-list-circleci-ip: configure/aws-white-list-circleci-ip@1.0.0
  aws-cli: circleci/aws-cli@0.1.13

jobs:
  aws_setup:
    docker:
      - image: cimg/python:3.11.0
    steps:
      - aws-cli/install
      - aws-white-list-circleci-ip/add
  build:
    docker:
      - image: cimg/node:18.4

    steps:
      - checkout
      - run: node --version
      - restore_cache:
          name: Restore Npm Package Cache
          keys:
            # Find a cache corresponding to this specific package-lock.json checksum
            # when this file is changed, this key will fail
            - v1-npm-deps-{{ checksum "package-lock.json" }}
            # Find the most recently generated cache used from any branch
            - v1-npm-deps-
      - run: npm install
      - run:
          name: start the server
          command: npm start
          background: true
      - save_cache:
          name: Save Npm Package Cache
          key: v1-npm-deps-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: run tests
          command: npm run test
      - aws-white-list-circleci-ip/remove

workflows:
  build-workflow:
    jobs:
      - aws_setup:
          context: aws_context
      - build:
          requires:
            - aws_setup
          context: aws_context

我的上下文环境

AWS_ACCESS_KEY_ID   
AWS_DEFAULT_REGION
AWS_SECRET_ACCESS_KEY
GROUPID

错误

在此处输入图像描述

我正在使用的球体https://circleci.com/developer/orbs/orb/configure/aws-white-list-circleci-ip

我想通了

version: 2.1

orbs:
  aws-cli: circleci/aws-cli@0.1.13

jobs:
  build:
    docker:
      - image: cimg/python:3.11.0-node
    steps:
      - checkout
      - run: node --version
      - restore_cache:
          name: Restore Npm Package Cache
          keys:
            # Find a cache corresponding to this specific package-lock.json checksum
            # when this file is changed, this key will fail
            - v1-npm-deps-{{ checksum "package-lock.json" }}
            # Find the most recently generated cache used from any branch
            - v1-npm-deps-
      - run: npm install
      - aws-cli/install
      - run:
          command: |
            public_ip_address=$(wget -qO- http://checkip.amazonaws.com)
            echo "this computers public ip address is $public_ip_address"
            aws ec2 authorize-security-group-ingress --region $AWS_DEFAULT_REGION --group-id $GROUPID --ip-permissions "[{\"IpProtocol\": \"tcp\", \"FromPort\": 22, \"ToPort\": 7000, \"IpRanges\": [{\"CidrIp\": \"${public_ip_address}/32\",\"Description\":\"CircleCi\"}]}]"
      - save_cache:
          name: Save Npm Package Cache
          key: v1-npm-deps-{{ checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: run tests
          command: npm run test

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
  build-workflow:
    jobs:
      - build:
          context: aws_context

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM