Skip to content

Latest commit

 

History

History
98 lines (78 loc) · 4.83 KB

README.md

File metadata and controls

98 lines (78 loc) · 4.83 KB

04_05_ci_cd_for_container_images

Recommended Reading

Using the Exercise Files

1. Create a repo; add service account credentials

  1. Create a new repo.
  2. Review the steps in Create a Service Account to add service account credentials to the repo

2. Create a repo in the Elastic Container Registry (ECR); Push an image

  1. In your AWS account, go the ECR homepage

  2. Select Get started.

  3. Under settings, confirm Private is selected

  4. Give the repo a name.

    For our deployment workflow to operate correctly, the container repo needs to have the same name as the GitHub repo.

  5. Keep the defaults for everything else, scroll to the bottom, and select Create repository.

  6. Back in the GitHub repo, use the workflow dispatch trigger to start a new run of the Container Deployment pipeline.

  7. Wait for the workflow run to complete. It will likely fail.

  8. On the ECR page, select the repo you created earlier.

  9. Confirm that an image has been pushed to the repo.

3. Create two App Runner services

  1. Browse to the App Runner homepage

  2. Create an App Runner service for the Staging environment.

    1. Select Create an App Runner service or Create service.

    2. Under Source, confirm Container registry and Amazon ECR are selected.

    3. Under Container image URI, select Browse.

    4. Select the image repo you created and confirm the latest appears under Image tag.

    5. Select Continue.

    6. Under Deployment settings, select Automatic.

      This will configure App Runner to watch our container repo in ECR. When a new image is pushed, the service will be updated with the new image right away.

    7. Under ECR access role, select Create new service role. If you already have a service role in place, select Use existing service role and select the role.

    8. Select Next.

    9. Enter a name for the service. Add staging as a prefix or suffix so you can identify the service. You may also consider using the repo name here as well.

    10. Under Virtual CPU, select 0.25 VCPU.

    11. Leave everything else as the defaults and go to the next screen by selecting Next.

    12. Review your settings, scroll to the bottom of the screen, and select Create & Deploy.

  3. Create an App Runner service for the Production environment.

    Use the same steps and settings as Staging with one exception:

    For the Production service, make sure that the Manual trigger is selected.

4. Create environments for the App Runner services

  1. Select each App Runner service and save the values for:

    • Default domain
    • Service ARN
  2. Back in the repo, create an environment for Production. (The Staging environment should already be in place, created by a workflow run.)

    1. Select Settings -> Environments -> New environment.
    2. For the name, Production.
    3. Select Configure environment.
    4. Select Required reviewers.
    5. In the search field, enter your GitHub user name and select it.
    6. Select Save protection rules.
    7. Under Environment variables, select Add variable.
    8. Create variables for SERVICE_ARN and URL using the values from the App Runner configuration for Production.
    9. Select Save protection rules.
  3. Edit the Staging environment.

  4. Under Environment variables, select Add variable.

  5. Create variables for SERVICE_ARN and URL using the values from the App Runner configuration for Staging.

5. Run the workflow

  1. Select the Actions tab.
  2. Select 0-Container Deployment Pipeline.
  3. Select Run workflow -> Run workflow.
  4. Observe the pipeline's progress.
  5. When prompted, select Review deployments.
  6. Select Production -> Approve and deploy.
  7. Observe the pipeline's progress.
  8. Follow the links on the tiles for each job to view the deployed application.

6. Remove the resources

To avoid costs associated with running resources in AWS, please remove them.

  1. Remove App Runner services:
    1. Browse to the App Runner homepage
    2. For each service:
    3. Select the service.
    4. Select Actions -> Delete.
    5. Enter the word delete and select Delete.
  2. Remove ECR repos.
    1. Browse to the ECR homepage
    2. Select the checkbox next to the name of the repo.
    3. Select Delete.
    4. Enter the word delete and select Delete.