This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-19
Channels
- # announcements (4)
- # aws (9)
- # babashka (1)
- # beginners (41)
- # cider (13)
- # clojure (45)
- # clojure-europe (16)
- # clojure-hungary (3)
- # clojure-norway (6)
- # clojure-uk (6)
- # clojurescript (14)
- # clr (3)
- # css (1)
- # datalevin (2)
- # datomic (2)
- # fulcro (8)
- # introduce-yourself (6)
- # jobs (3)
- # malli (2)
- # nbb (49)
- # off-topic (3)
- # reitit (23)
- # shadow-cljs (36)
- # tools-deps (2)
My toy cf template fails. I shall resolve to understand why in the morning. The error is
Requested attribute Arn does not exist in schema for AWS::ECS::TaskDefinition
and i don't understand why because i feel like it should have an Arn.
My worry is that you have to have a cluster that the task definition is part of. Though that doesn't make sense to me because i thought the point of fargate was that you didn't have to do that.
AWSTemplateFormatVersion: 2010-09-09
Description: The template used to create an ECS Task definition from the ECS Console.
Resources:
JarCreator:
Type: 'AWS::ECS::TaskDefinition'
Properties:
ContainerDefinitions:
- LogConfiguration:
Options:
awslogs-group: /ecs/tiny-function-task
awslogs-region: us-east-2
awslogs-stream-prefix: ecs
awslogs-create-group: 'true'
LogDriver: awslogs
Name: tiny-function
Image: ''
Essential: true
PortMappings: []
EnvironmentFiles: []
Family: tiny-function-task
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
Cpu: .5 vCPU
Memory: 1 GB
RuntimePlatform:
CpuArchitecture: X86_64
OperatingSystemFamily: LINUX
ExecutionRoleArn: 'arn:aws:iam::595680822218:role/ecsTaskExecutionRole'
Tags:
- Key: 'ecs:taskDefinition:createdFrom'
Value: ecs-console-v2
- Key: 'ecs:taskDefinition:stackId'
Value: !Ref 'AWS::StackId'
Metadata:
'AWS::CloudFormation::Designer':
id: 3b65a475-eeb6-45ea-b1f5-314e0b332333
Hourly:
Type: 'AWS::Events::Rule'
Properties:
Description: it does things you cant imagine
ScheduleExpression: rate(1 hour)
State: Enabled
Targets:
- Arn: !GetAtt
- JarCreator
- Arn
ID: "Id123"
EcsParameters:
TaskDefinationArn: !Ref JarCreator
EnableExecuteCommand: True
LaunchType: FARGATE
Outputs:
TaskDefinitionARN:
Description: The created task definition ARN.
Value: !Ref JarCreator
It has been a few years since I tangled with cloudformation, but if recall you can think of a resource definition as sort of an expression that evaluates to creating the resource
The result of creating the resource is some value, which is bound to the name of the resource !Ref gets you the value bound to the name
The value returned from creating the resource is not always the arn is the tricky thing
Exactly what hiredman says. See Return values section here https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecs-taskdefinition.html
You're trying to reference attribute abc.Arn but you get the arn with just referencing abc
@drewverlee Yeah in this case it looks like TaskDefinition does return the Arn with Ref, but Arn isn't availble with GetAtt, and you attempt to get it with GettAtt in the hourly rule. https://theburningmonk.com/cloudformation-ref-and-getatt-cheatsheet/ This list I linked before will show what is returned/available with GetAtt all in one place
Thanks everyone. I think the more fundamental issue is that i was trying to target the task definition resource directly instead of the <AWS::ECS::Service|AWS::ECS::Servic>e that runs the task. I thought with fargate you didn't need to even reference this layer, but that doesn't seem to be the case.