From fc92d71835fb6bf96fe7612b4b5984bf3678e410 Mon Sep 17 00:00:00 2001 From: Weder Ribas Date: Mon, 20 Jan 2025 22:50:09 -0800 Subject: [PATCH] Implement multiple fixes for ECR-ECR tutorial --- .../tutorials/ecs-ecr-container-app/index.md | 22 +++++++++---------- layouts/shortcodes/github.html | 6 ++++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/content/en/tutorials/ecs-ecr-container-app/index.md b/content/en/tutorials/ecs-ecr-container-app/index.md index ec4f8ee5bf..7acf910203 100644 --- a/content/en/tutorials/ecs-ecr-container-app/index.md +++ b/content/en/tutorials/ecs-ecr-container-app/index.md @@ -65,19 +65,18 @@ Next, we will create an ECR repository to push our Docker image. We will use the `awslocal` CLI to create the repository. {{< command >}} -$ awslocal ecr create-repository --repository-name +$ awslocal ecr create-repository --repository-name sample-ecr-repo {{< / command >}} -Replace `` with your desired repository name. The output of this command will contain the `repositoryUri` value that we'll need in the next step: ```json { "repository": { - "repositoryArn": "arn:aws:ecr:us-east-1:000000000000:repository/", + "repositoryArn": "arn:aws:ecr:us-east-1:000000000000:repository/sample-ecr-repo", "registryId": "000000000000", - "repositoryName": "", - "repositoryUri": "localhost.localstack.cloud:4510/", + "repositoryName": "sample-ecr-repo", + "repositoryUri": "localhost.localstack.cloud:4510/sample-ecr-repo", "createdAt": "", "imageTagMutability": "MUTABLE", "imageScanningConfiguration": { @@ -111,7 +110,7 @@ We can now create an ECS cluster and deploy our NGINX web server. LocalStack enables the deployment of ECS task definitions, services, and tasks, allowing us to deploy our ECR containers via the ECS Fargate launch type, which uses the local Docker engine to deploy containers locally. To create the necessary ECS infrastructure on our local machine before deploying our NGINX web server, we will use a CloudFormation template. -You can create a new file named `ecs.infra.yml` inside a new `templates` directory, using a [publicly available CloudFormation template as a starting point](https://github.com/awslabs/aws-cloudformation-templates/blob/master/aws/services/ECS/FargateLaunchType/clusters/public-vpc.yml). +You can create a new file named `ecs.infra.yml` inside a new `templates` directory, using a [publicly available CloudFormation template as a starting point](https://github.com/aws-cloudformation/aws-cloudformation-templates/blob/main/ECS/FargateLaunchType/services/public-service.yaml). To begin, we'll add the `Mappings` section and configure the subnet mask values, which define the range of internal IP addresses that can be assigned. ```yaml @@ -373,14 +372,13 @@ Outputs: To deploy the CloudFormation template we created earlier, use the following command: {{< command >}} -$ awslocal cloudformation create-stack --stack-name --template-body file://templates/ecs.infra.yml +$ awslocal cloudformation create-stack --stack-name infra --template-body file://templates/ecs.infra.yml {{< /command >}} -Make sure to replace `` with a name of your choice. Wait until the stack status changes to `CREATE_COMPLETE` by running the following command: {{< command >}} -$ awslocal cloudformation wait stack-create-complete --stack-name +$ awslocal cloudformation wait stack-create-complete --stack-name infra {{< /command >}} You can also check your deployed stack on the LocalStack Web Application by navigating to the [CloudFormation resource browser](https://app.localstack.cloud/resources/cloudformation/stacks). @@ -549,14 +547,14 @@ Resources: Next, let's deploy the CloudFormation template by running the following command: {{< command >}} -$ awslocal cloudformation create-stack --stack-name --template-body file://templates/ecs.sample.yml --parameters ParameterKey=ImageUrl,ParameterValue= +$ awslocal cloudformation create-stack --stack-name ecs --template-body file://templates/ecs.sample.yml --parameters ParameterKey=ImageUrl,ParameterValue= {{< /command >}} -Replace `` with a name of your choice and `` with the URI of the Docker image that you want to deploy. +Replace `` with the URI of the Docker image that you want to deploy. Wait for the stack to be created by running the following command: {{< command >}} -$ awslocal cloudformation wait stack-create-complete --stack-name +$ awslocal cloudformation wait stack-create-complete --stack-name ecs {{< /command >}} Now that the ECS service has been deployed successfully, let's access the application endpoint. diff --git a/layouts/shortcodes/github.html b/layouts/shortcodes/github.html index 2f6632bac2..c71271d412 100644 --- a/layouts/shortcodes/github.html +++ b/layouts/shortcodes/github.html @@ -2,7 +2,11 @@ {{ if (.Get "ref") }} {{ $ref = printf "?ref=%s" (.Get "ref") }} {{ end }} -{{ $json := resources.GetRemote "https://api.github.com/repos/" (.Get "repo") "/contents/" (.Get "file") $ref }} +{{ $url := "https://api.github.com/repos/" }} +{{ $opts := dict + (.Get "repo") "/contents/" (.Get "file") $ref +}} +{{ $json := resources.GetRemote $url $opts }} {{ $data := $json | transform.Unmarshal }} {{ $con := base64Decode $data.content }} {{ $content := "" }}