We should just automatically round up to the valid cpu and mem values in Fargate so even if someone enters an invalid mem/cpu combo it doesn't stop them from building and deploying.
in user-experience spirit, this may be related to https://github.com/aws/copilot-cli/issues/1625
to comment further on user experience, i ran into this vague error via:
copilot job init
# edit manifest
copilot job deploy
The manifest edit was where I introduced illegal values for fargate cpu units.
name: conntest
type: Scheduled Job
on:
schedule: "@every 25m"
timeout: 30m
image:
build: Dockerfile-conntest
cpu: 128 # Number of CPU units for the task.
memory: 256 # Amount of memory in MiB used by the task.
entrypoint: "./run-my-tests.py"
I was using tiny values because this is all that's in my Dockerfile
FROM alpine:3.2 AS builder
RUN apk update && apk upgrade && apk add curl wget bash jq netcat-openbsd
FROM builder AS deploy
COPY --from=builder /bin /bin
COPY --from=builder /usr /usr
COPY --from=builder /sbin /sbin
CMD ["/bin/ash"]
the subsequent deploy command yields this error:
Invalid request provided: Create TaskDefinition:
No Fargate configuration exists for given values.
(Service: AmazonECS; Status Code: 400;
Error Code: ClientException;
Request ID: 3d7530c5-bfb4-6a4e-8a2a-53a3561b8f74;
Proxy: null)
for anyone finding this, valid values are here
| CPU value | Memory value (MiB) |
| -------------- | ---------------------------------------------------------------------------------- |
| 256 (.25 vCPU) | 512 (0.5GB), 1024 (1GB), 2048 (2GB) |
| 512 (.5 vCPU) | 1024 (1GB), 2048 (2GB), 3072 (3GB), 4096 (4GB) |
| 1024 (1 vCPU) | 2048 (2GB), 3072 (3GB), 4096 (4GB), 5120 (5GB), 6144 (6GB), 7168 (7GB), 8192 (8GB) |
| 2048 (2 vCPU) | Between 4096 (4GB) and 16384 (16GB) in increments of 1024 (1GB) |
| 4096 (4 vCPU) | Between 8192 (8GB) and 30720 (30GB) in increments of 1024 (1GB) |
Note:
An error occurred (ClientException) when calling the RegisterTaskDefinition operation:
Invalid 'cpu' setting for task.
For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.
is more helpful than
Error: ClientException: No Fargate configuration exists for given values.
I'm guessing the second error is being returned by the Go module being used here. In my opinion, returning a helpful error message is better than rounding up. Something like this that impacts cost, however trivial, should be made by the end user.
@camilosantana you've just saved me, I had 1048 instead of 1024 as my CPU
We really need better manifest and CF validation, I keep running into these issues all the time.
Most helpful comment
for anyone finding this, valid values are here
| CPU value | Memory value (MiB) |
| -------------- | ---------------------------------------------------------------------------------- |
| 256 (.25 vCPU) | 512 (0.5GB), 1024 (1GB), 2048 (2GB) |
| 512 (.5 vCPU) | 1024 (1GB), 2048 (2GB), 3072 (3GB), 4096 (4GB) |
| 1024 (1 vCPU) | 2048 (2GB), 3072 (3GB), 4096 (4GB), 5120 (5GB), 6144 (6GB), 7168 (7GB), 8192 (8GB) |
| 2048 (2 vCPU) | Between 4096 (4GB) and 16384 (16GB) in increments of 1024 (1GB) |
| 4096 (4 vCPU) | Between 8192 (8GB) and 30720 (30GB) in increments of 1024 (1GB) |
Note:
is more helpful than
I'm guessing the second error is being returned by the Go module being used here. In my opinion, returning a helpful error message is better than rounding up. Something like this that impacts cost, however trivial, should be made by the end user.