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

Consider supporting policy transformations #108

Closed
joeduffy opened this issue Sep 16, 2019 · 4 comments
Closed

Consider supporting policy transformations #108

joeduffy opened this issue Sep 16, 2019 · 4 comments
Assignees
Labels
kind/enhancement Improvements or new features resolution/fixed This issue was fixed

Comments

@joeduffy
Copy link
Member

A user had the suggestion to allow write operations from policies. Two examples:

  1. A policy could come packaged with an "auto-fixer" (e.g., "no public load balancers" could automatically turn all load balancers into private ones)
  2. An org-wide transformation could apply a standard rewrite (e.g., "add a standard tag to all resources")

This seems like a very powerful capability — but potentially very dangerous and/or confusing also, and probably one where you'd want dials to control what rewrites were allowed to run where.

@joeduffy
Copy link
Member Author

joeduffy commented Apr 10, 2020

@lukehoban @leezen , both @clstokes and I had a conversation with a customer today that effectively distills down to this. As they said today, "it's great to block deployments if tags are missing, but even better to just inject the right tags automatically for all of our stacks in the first place." I do wonder where this belongs -- as it's somewhere between transformations and policies.

@yellowhat
Copy link

yellowhat commented Apr 16, 2021

I am trying to create a policy to check for tags:

def tags_validator(args: ResourceValidationArgs, report_violation: ReportViolation):
    if "tags" in args.props:
        tags = args.props["tags"]
        for tag in ["Project"]:
            if tag not in tags:
                report_violation("Must have a tag name {tag}")

tags = ResourceValidationPolicy(
    name="tags",
    description="Must have tags and specific one",
    validate=tags_validator,
)

PolicyPack(
    name="azure-python",
    enforcement_level=EnforcementLevel.MANDATORY,
    policies=[
        tags,
    ],
)

But not violation is reported if no tags are assigned to a resource.

Instead using:

    if "tags" not in args.props:
        report_violation("Must have a tags")

will report a violation even if no tags can be assigned to the resource (ie azure.network.Subnet)

@infin8x infin8x added kind/enhancement Improvements or new features and removed enhancement labels Jul 10, 2021
@justinvp justinvp removed their assignment Nov 24, 2022
@justinvp justinvp added the resolution/fixed This issue was fixed label Jul 17, 2024
@justinvp
Copy link
Member

This was fixed with #314 (and associated CLI changes)

@pulumi-bot pulumi-bot reopened this Jul 17, 2024
@pulumi-bot
Copy link

Cannot close issue:

  • does not have an assignee

Please fix these problems and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

7 participants