org-formation-cli icon indicating copy to clipboard operation
org-formation-cli copied to clipboard

!GetAtt for CurrentAccount.Tags.<key> returns [object object]

Open Lux-CC opened this issue 3 years ago • 9 comments

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].

Lux-CC avatar Jul 10 '21 23:07 Lux-CC

great, thanks!

OlafConijn avatar Jul 10 '21 23:07 OlafConijn

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

OlafConijn avatar Jul 11 '21 13:07 OlafConijn

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.

Lux-CC avatar Jul 11 '21 16:07 Lux-CC

indeed - that doesn't seem super useful :).

now, just created a new beta npm i [email protected]. let me know whether that works better.

OlafConijn avatar Jul 11 '21 22:07 OlafConijn

Oh damn, I think I'm an idiot :P. I used !Ref instead of !GetAtt. !Ref still returns [object object] for CurrentAccount.Tags.. I guess that's also unintended behavior, but at least GetAtt was working as it's supposed to.

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!

Lux-CC avatar Jul 12 '21 11:07 Lux-CC

!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 ☺️

OlafConijn avatar Jul 12 '21 11:07 OlafConijn

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.

Lux-CC avatar Jul 12 '21 11:07 Lux-CC

sounds like a great idea

OlafConijn avatar Jul 12 '21 14:07 OlafConijn

i think this is kinda related to #259

zaro0508 avatar Dec 27 '21 16:12 zaro0508