Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

we want to deploy all services by one command #3474

Open
TakaraShinya opened this issue Apr 19, 2022 · 4 comments
Open

we want to deploy all services by one command #3474

TakaraShinya opened this issue Apr 19, 2022 · 4 comments
Labels
area/deployment Issues related to deployments type/feature Issues that are new feature requests. type/request Issues that are created by customers.

Comments

@TakaraShinya
Copy link

I have some services in an app.
For example,

  • web-svc(Load Balanced Web Service)
  • mysql-svc(Backend Service)
  • redis-svc(Backend Service)

I am aware that AWS Copilot CLI is not yet in a position to deploy all services in a single command execution.
so, we want to deploy all services by one command.

because, I want to use this cli for our ci test env.

  • 1️⃣ first, i edited code and push github remote branch
  • 2️⃣ second, i will create pull request for review, and create an application env for review.

but, we couldn't create it simply.

If I just don't know how to do that, please let me know.

@Lou1415926
Copy link
Contributor

Hello @TakaraShinya ! Thank you for the request! Let me see if I can figure out a way to do it with the current Copilot.

Create an application env for review.

Just so that my understanding is correct - when a new GitHub push happens, you'd like to create a new environment, deploy all services to that new environment, and then after maybe some testings, destroy the environment. Is that accurate?

@TakaraShinya
Copy link
Author

Hello @Lou1415926

when a new GitHub push happens, you'd like to create a new environment, deploy all services to that new environment, and then after maybe some testings, destroy the environment. Is that accurate?

Yes, it is correct. Thank you for your understanding. 🙇
If you could figure out a way to do, please teach me. 🙇‍♂️

@Lou1415926 Lou1415926 added type/feature Issues that are new feature requests. type/request Issues that are created by customers. area/deployment Issues related to deployments labels Apr 21, 2022
@Lou1415926
Copy link
Contributor

Hello @TakaraShinya ! Sorry for getting back to you late!

Your feature request makes sense - it'd be convenient if all services can be deployed with one single command.

For now, I wonder would it be acceptable in your case to use some scripting to automate the steps that you've described? For example, if written in shell script:

copilot env init --name test-timestamp
svcs=$(copilot svc ls --json | jq -r '.services[].name')
for svc in $svcs; do
  copilot svc deploy --env test-timestamp ;
  if [ $? -ne 0 ]; then
    echo "Some error occurred." 1>&2;
    exit 1;
  fi
done;

@TakaraShinya
Copy link
Author

Thank you, @Lou1415926 !

For now, I wonder would it be acceptable in your case to use some scripting to automate the steps that you've described?

Yes! I have tried it.
I have automated the following by the Github Actions. :octocat:
but i think, it is too long. 💦 😓 How do you think ❓ 🤔

i think, if copilot cli has all service deploy and check exist service,
maybe this workflow is more simple. 👀 🙄

      - name: Delete your Copilot Application
        if: "contains(github.event.head_commit.message, '[close copilot]')"
        continue-on-error: true
        run: |
          echo "copilot version check 👀"
          copilot --version
          echo "👋👋👋 Delete copilot your app 💪"
          copilot app delete -n app-${BRANCH_NAME} --yes # 困ったらこれ使って一度削除

      - name: check copilot version and app init
        if: "contains(github.event.head_commit.message, '[start copilot]')"
        id: check_copilot_app_exist
        run: |
          echo "copilot version check 👀"
          copilot --version
          echo "copilot make your app 💪"
          copilot app init app-${BRANCH_NAME} --domain example.com

      - name: check copilot env exist
        if: "contains(github.event.head_commit.message, '[start copilot]')"
        id: check_env_exist
        continue-on-error: true
        run: |
          echo "Show Target Env for copilot 👀"
          copilot env show -a app-${BRANCH_NAME} --name ${BRANCH_NAME}

      - name: when NOT exist copilot target env
        if: ${{ steps.check_env_exist.outcome == 'failure' && contains(github.event.head_commit.message, '[start copilot]') }}
        run: |
          echo "not exist copilot target env"
          # VPC import
          copilot env init -a app-${BRANCH_NAME} --name ${BRANCH_NAME} --profile XXXXXX \
          --import-vpc-id vpc-XXXXXXX \
          --import-public-subnets subnet-XXXXXX,subnet-XXXXXXX \
          --import-private-subnets subnet-XXXXXXX,subnet-XXXXXX

      # <Backend Serviceからデプロイ>
      # <mysql-svc>
      - name: check MySQL service exist
        if: "contains(github.event.head_commit.message, '[start copilot]')"
        id: check_mysql_svc_exist
        continue-on-error: true
        run: |
          copilot svc show -a app-${BRANCH_NAME} --name mysql-svc

      # service initが未完ならやる
      - name: when NOT exist copilot MySQL service
        if: ${{ steps.check_mysql_svc_exist.outcome == 'failure' && contains(github.event.head_commit.message, '[start copilot]') }}
        run: |
          echo "not exist copilot MySQL service"
          echo "Init Service for MySQL"
          copilot svc init -a app-${BRANCH_NAME} --name mysql-svc

      # <redis-svc>
      - name: check redis service exist
        if: "contains(github.event.head_commit.message, '[start copilot]')"
        id: check_redis_svc_exist
        continue-on-error: true
        run: |
          copilot svc show -a app-${BRANCH_NAME} --name redis-svc

      # service init未完ならやる
      - name: when NOT exist copilot redis service
        if: ${{ steps.check_redis_svc_exist.outcome == 'failure' && contains(github.event.head_commit.message, '[start copilot]') }}
        run: |
          echo "not exist copilot redis service"
          echo "Init Service for redis"
          copilot svc init -a app-${BRANCH_NAME} --name redis-svc

      # <web-svc>
      - name: check web service exist
        if: "contains(github.event.head_commit.message, '[start copilot]')"
        id: check_web_svc_exist
        continue-on-error: true
        run: |
          copilot svc show -a app-${BRANCH_NAME} --name web-svc

      # service init未完ならやる
      - name: when NOT exist copilot web service
        if: ${{ steps.check_web_svc_exist.outcome == 'failure' && contains(github.event.head_commit.message, '[start copilot]') }}
        run: |
          echo "not exist copilot web service"
          echo "Init Service for web"
          copilot svc init -a app-${BRANCH_NAME} --name web-svc

      # all svc deploy
      - name: deploy all service
        if: "contains(github.event.head_commit.message, '[start copilot]')"
        run: |
          copilot svc deploy -a app-${BRANCH_NAME} --name mysql-svc --env ${BRANCH_NAME}
          copilot svc deploy -a app-${BRANCH_NAME} --name redis-svc --env ${BRANCH_NAME}
          copilot svc deploy -a app-${BRANCH_NAME} --name web-svc --env ${BRANCH_NAME}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deployment Issues related to deployments type/feature Issues that are new feature requests. type/request Issues that are created by customers.
Projects
None yet
Development

No branches or pull requests

2 participants