Oran Erez

05/04/2023, 8:46 AM
Hi Everyone, I have an issue with Atlantis for the following scenario: I'm having resources which includes spaces in the name. i.e.:
module.snowflake.snowflake_role_grants.bp_role_to_admins["SUPPORT LEADERS"]
As can be seen there is a space between SUPPORT and LEADERS words. The issue is that I'm also using targeting resources on daily basis. As a result that leads me to use the following syntax in order to use the targeting option:
atlantis plan -p stg-us-west-2 -- -target='module.snowflake.snowflake_role_grants.bp_role_to_admins["SUPPORT LEADERS"]'
and the support of built-in environment variable
with some customization workflow to manipulate the give string (could be few resources as well), i.e.:
- env: 
          name: TARGET_PARAMS
          command: echo "$COMMENT_ARGS" | sed s/'\\'/''/g | sed 's/,/ /g'
      - run: terraform init -input=false
      - run: terraform workspace select $WORKSPACE
      - run: terraform plan $TARGET_PARAMS -input=false -refresh -out $PLANFILE
Atlantis is not able to handle the space correctly, no matter what manipulation i'm trying to do end up with the following error:
│ Error: Invalid target "module.snowflake.snowflake_role_grants.bp_role_to_admins[SUPPORT"
│ Index brackets must contain either a literal number or a literal string.
Is there a way to handle the space while keeping the resource name intact? Thanks in advanced.

PePe Amengual

05/04/2023, 3:42 PM
I see your issue and from experience I would say change the index name because you are going to have recurrent issues not just with Atlantis but other cicd tools
you are in shell escaping hell right now

Oran Erez

05/04/2023, 3:43 PM
totally correct
I will try to convince the service owner to change the name asap
otherwise I'm quite doomed with it