Closed basilk27 closed 1 year ago
The issue seems to be caused by this command returning no task ARN (as shown in the script's ECS Task: None
output): aws ecs list-tasks --cluster $CLUSTER_NAME --output text --query 'taskArns[0]
Consequently, aws ecs describe-tasks --cluster $CLUSTER_NAME --tasks $TASK_ARN
will be run with "None" as $TASK_ARN
, which in turn is the cause for the "An error occurred (InvalidParameterException) when calling the DescribeTasks operation: taskId length should be one of [32,36]" error message (since "None" has a length of 4, rather than 32 or 36 characters, besides it of course not being a valid ARN anyway).
I've checked your Docker image, which seems to be accessible. However, looking at that image's configuration, I can see that uses a "linux/arm64/v8" architecture (rather than the "linux/amd64" one used by the default Stratospheric image under https://hub.docker.com/r/stratospheric/todo-app-v1/tags): https://hub.docker.com/r/basilk27/todo-app-v1/tags
Maybe, this causes an ECS startup failure.
While building the image on M1 mac, was getting the "linux/arm64/v8" I changed the build image command to
docker build --platform linux/arm64 -t basilk27/todo-app-v1:latest
and was able to get the architecture of "linux/amd64"
While building the image on M1 mac, was getting the "linux/arm64/v8" I changed the build image command to
docker build --platform linux/arm64 -t basilk27/todo-app-v1:latest
and was able to get the architecture of "linux/amd64"
Did this change in CPU architecture resolve your issue?
Closing this issue for now. If it still doesn't work, please reopen.
"When I run create the first time I do get the None but then I re-run the create script without running the delete script, then at that time it deploys the app but on running it I get nothing back on but much info in the log file."
When working on an arm64
architecture (e.g. the Apple Silicon M1/M2), make sure to create a Docker image that works for amd64
. The sample ECS environment we're deploying the Docker container to expects amd64
. ECS supports arm64
but this needs to be configured.
This article describes how to do it using Docker's buildx
feature.
More information: "I did the run of the create.sh script again and looking at the log file on AWS it’s giving an error on exec /opt/java/openjdk/bin/java: exec format error. Please do note that I am running create.sh two times in the log below as to be able to get the ECS Task. ~/Dev/amazon-ch01/cloudformation ./create.sh ...
Below is the log info. 2/7/2023, 9:07:48 AM exec /opt/java/openjdk/bin/java: exec format error stratospheric-todo-app Looking at the Log events, I see Below 2023-02-07T09:07:48.920-05:00 Copy exec /opt/java/openjdk/bin/java: exec format error exec /opt/java/openjdk/bin/java: exec format error"
This error likely is still caused by a mismatch in CPU architectures: "exec /opt/java/openjdk/bin/java: exec format error stratospheric-todo-app"
See https://mkyong.com/java/bash-usr-bin-java-cannot-execute-binary-file-exec-format-error/
Hi Bjorn and Philip, Thanks for the help - this did help - https://blog.jaimyn.dev/how-to-build-multi-architecture-docker-images-on-an-m1-mac/ Issue resolved
What's going wrong and not working?
Hi All, I am a new-be on AWS and just got your book ‘From Zero to Production with Spring Boot and AWS’ Getting an error while deploying the todo-app-v1. I have the image “basilk27/todo-app-v1” as my docker image. I also did make a change to the create.sh as to pick up my image. It looks like it’s not able to pick up my docker image from the registry Below is the error am getting StackId: arn:aws:cloudformation:us-east-1:740757785710:stack/stratospheric-basic-network/d7ba9e80-a046-11ed-a078-120638875349 StackId: arn:aws:cloudformation:us-east-1:740757785710:stack/stratospheric-basic-service/fc79d0b0-a046-11ed-a8af-12dcfcb90ced ECS Cluster: stratospheric-basic-network-ECSCluster-5LaiQPddr0N3 ECS Task: None An error occurred (InvalidParameterException) when calling the DescribeTasks operation: taskId length should be one of [32,36] Network Interface: Public IP: 3.90.113.109 You can access your service at http://3.90.113.109:8080/
my create script is like this
Turning off the AWS pager so that the CLI doesn’t open an editor for each command result
export AWS_PAGER=“” aws cloudformation create-stack \ --stack-name stratospheric-basic-network \ --template-body file://network.yml/ \ --capabilities CAPABILITY_IAM aws cloudformation wait stack-create-complete \ --stack-name stratospheric-basic-network aws cloudformation create-stack \ --stack-name stratospheric-basic-service \ --template-body file://service.yml/ \ --parameters \ ParameterKey=NetworkStackName,ParameterValue=stratospheric-basic-network \ ParameterKey=ServiceName,ParameterValue=stratospheric-todo-app \ ParameterKey=ImageUrl,ParameterValue=docker.io/basilk27/todo-app-v1:latest \ ParameterKey=ContainerPort,ParameterValue=8080 aws cloudformation wait stack-create-complete --stack-name stratospheric-basic-service CLUSTER_NAME=$(aws cloudformation describe-stacks --stack-name stratospheric-basic-network --output text --query ‘Stacks[0].Outputs[?OutputKey==
ClusterName
].OutputValue | [0]’) echo “ECS Cluster: ” $CLUSTER_NAME TASK_ARN=$(aws ecs list-tasks --cluster $CLUSTER_NAME --output text --query ‘taskArns[0]’) echo “ECS Task: ” $TASK_ARN ENI_ID=$(aws ecs describe-tasks --cluster $CLUSTER_NAME --tasks $TASK_ARN --output text --query ‘tasks[0].attachments[0].details[?name==networkInterfaceId
].value’) echo “Network Interface: ” $ENI_ID PUBLIC_IP=$(aws ec2 describe-network-interfaces --network-interface-ids $ENI_ID --output text --query ‘NetworkInterfaces[0].Association.PublicIp’) echo “Public IP: ” $PUBLIC_IP echo “You can access your service at http://$PUBLIC_IP:8080"Expected outcome
when I change this value below to point to my docker image it's not working. ParameterKey=ImageUrl,ParameterValue=docker.io/stratospheric/todo-app-v1:latest
I change that like to ParameterKey=ImageUrl,ParameterValue=docker.io/basilk27/todo-app-v1:latest
but it's not working. What am I doing wrong. Thanks