Created
November 14, 2022 04:03
-
-
Save timmyers/112497a4aa756fbcdaf51ee18f5fa66a to your computer and use it in GitHub Desktop.
Initial CrossGuard Policy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as aws from '@pulumi/aws'; | |
import { PolicyPack, ReportViolation, validateResourceOfType } from '@pulumi/policy'; | |
new PolicyPack('aws', { | |
policies: [ | |
{ | |
name: 'required-tags', | |
description: 'Certain tags are required.', | |
enforcementLevel: 'mandatory', | |
validateResource: [ | |
validateResourceOfType(aws.iam.User, (user, args, reportViolation) => { | |
requireCreatorTag(user.tags, reportViolation); | |
}), | |
], | |
}, | |
], | |
}); | |
function requireCreatorTag(tags: any, reportViolation: ReportViolation) { | |
if ((tags || {})['Creator'] === undefined) { | |
reportViolation(`A 'Creator' tag is required.`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment