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

gcp - project - propagate-labels from resource hierarchy #6287

Merged
merged 6 commits into from
Nov 12, 2020

Conversation

kapilt
Copy link
Collaborator

@kapilt kapilt commented Nov 11, 2020

Propagate labels from the organization hierarchy to a project.
folder-labels should resolve to a json data mapping of folder path
to labels that should be applied to contained projects.
as a worked example assume the following resource hierarchy

      - /dev
           /network
              /project-a
           /ml
              /project-b

Given a folder-labels json with contents like

      {"dev": {"env": "dev", "owner": "dev"},
       "dev/network": {"owner": "network"},
       "dev/ml": {"owner": "ml"}

Running the following policy

      policies:
       - name: tag-projects
         resource: gcp.project
         # use a server side filter to only look at projects
         # under the /dev folder the id for the dev folder needs
         # to be manually resolved outside of the policy.
         query:
           - filter: "parent.id:389734459211 parent.type:folder"
         filters:
           - "tag:owner": absent
         actions:
           - type: propagate-tags
             folder-labels:
                url: file://folder-labels.json

Will result in project-a being tagged with owner: network and env: dev and project-b being tagged with owner: ml and env: dev

note gcp is restrictive on labels and we don't perform any pre-validation of labels.

@kapilt kapilt marked this pull request as ready for review November 12, 2020 16:47
@kapilt kapilt merged commit 45a9be9 into cloud-custodian:master Nov 12, 2020
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.

None yet

1 participant