org-formation-cli
org-formation-cli copied to clipboard
!GetAtt for CurrentAccount.Tags.<key> returns [object object]
Hey! I like to work with org-formation. I just stumbled upon this quirk:
Subject of the issue
When I use !GetAtt CurrentAccount.Tags.<tag key>
, it gets translated to an [object object] string instead of the value.
Your environment
- version of org-formation (v0.9.16)
Steps to reproduce
In organization.yml:
SharedSecurityAccount:
Type: OC::ORG::Account
Properties:
...other props here...
Tags:
EnvName: Test
I want to pass the tag to in task file to my cdk app:
OrgParams:
Type: update-cdk
Path: ./
CustomDeployCommand: !Sub npm ci && npm run build && npx cdk deploy --require-approval never${CurrentTask.Parameters} --all
Parameters:
EnvName: !GetAtt CurrentAcount.Tags
Expected behaviour
I expect there to be a -c EnvName=Test
when the command runs
Actual behaviour
Instead it runs with -c EnvName=[object object]
.
great, thanks!
hi! i just wrote the tests to verify whether this bug (still) exists on the branch i am using for the next release. i dont believe it does. could you try with the latest beta? npm i [email protected]
will soon release to main. latest beta should be stable. just need to write the documentation around the new features :)
https://github.com/org-formation/org-formation-cli/pull/252/commits/14a257712cacc62a7dc7b667ed5fb2847b9bbfe0
Unfortunately, when trying the beta I ran into the following error on the first task :P
Task OrganizationUpdate execute failed. reason: unable to load file organization.yml.
--
47 | reason: unexpected attribute TemplatingContext found on template root. expected attributes are AWSTemplateFormatVersion, Description, Organization, OrganizationBinding, DefaultOrganizationBinding, OrganizationBindings, DefaultOrganizationBindingRegion, OrganizationBindingRegion, Metadata, Parameters, Mappings, Conditions, Resources, Outputs, Transform, Globals, Definitions.
indeed - that doesn't seem super useful :).
now, just created a new beta npm i [email protected]
.
let me know whether that works better.
Oh damn, I think I'm an idiot :P. I used !Ref instead of !GetAtt. !Ref still returns [object object] for CurrentAccount.Tags.
Also, I see that in my initials message I actually wrote EnvName: !GetAtt CurrentAcount.Tags
instead of EnvName: !GetAtt CurrentAcount.Tags.EnvName
. Must have been a long day...
Anyway thanks for your help and I'm looking forward to using the framework more and more (and where I can try to contribute).
All the best!
!Ref only takes 1 argument. so you would be able to !Ref CurrentAccount
, but not !Ref CurentAccount.Name
.
likewise you would not be able to !GetAtt CurrentAccount
.
right or wrong, the above is how its implemented. i really enjoy learning what assumptions people have around this. either help by creating more/specific error messages or maybe improve the design.
thanks a lot! dank je wel ☺️
Yeah I was basically being stupid :P. I mean that !Ref CurentAccount.Name could maybe throw an error with maybe a hint ("Do you mean GetAtt?"), instead of returning an [object]. But I don't know if that makes sense :) . I'll try to add some error handling when I have time.
sounds like a great idea
i think this is kinda related to #259