Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed from string delimiter based paths to array based paths #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikkelramlov
Copy link

Problem
The main function: findAndReplace(obj, path) takes a string as path and relies on period as delimiter. That works well in most cases except when a key consist of a name with periods in it. My example is this:

  GithubActionRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: GithubActionRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Federated: !Ref OIDCProvider
            Action: sts:AssumeRoleWithWebIdentity
            Condition:
              StringEquals:
                token.actions.githubusercontent.com:aud: sts.amazonaws.com
              StringLike:
                token.actions.githubusercontent.com:sub:
                  - $forEach:
                      iterator: ${self:custom.sourceRepos}
                      template:
                        - 'repo:$forEach.value:*'

Notice

token.actions.githubusercontent.com:sub

in the Condition statement.

Solution

Utilize the lodash.get capability to use Array as path to a given property.

@mikkelramlov mikkelramlov requested a review from a team as a code owner February 6, 2023 13:40
@mikkelramlov mikkelramlov changed the title Changed from string delimiter based paths to array based. Changed from string delimiter based paths to array based paths. Feb 9, 2023
@mikkelramlov mikkelramlov changed the title Changed from string delimiter based paths to array based paths. Changed from string delimiter based paths to array based paths Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant