-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* management policies addition * management policies removal from K8-provider * load balancer controller addition * updating policy to access global and local index * Update dynamodb-write.yaml license * adding tags * adding tags object * adding tags object fix * adding tags object test * s3-irsa tag definition correction * s3-irsa tag parametrized
- Loading branch information
Showing
6 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Prevent provisioning resources that do not have the required tags | ||
|
||
This example covers a Gatekeeper policy that denies requests for provisioning | ||
resources without the required tags | ||
|
||
Examples and test cases are available under the `samples` directory. | ||
Tests can be ran using the [gator cli](https://open-policy-agent.github.io/gatekeeper/website/docs/gator/). | ||
|
||
To run tests for this example run: | ||
```bash | ||
cd examples/gatekeeper/required-tags/ | ||
gator verify . -v | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: AwsRequiredTags | ||
metadata: | ||
name: awsrequiredtags | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: ["*"] | ||
kinds: ["*"] | ||
parameters: | ||
tags: ["owner"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: templates.gatekeeper.sh/v1 | ||
kind: ConstraintTemplate | ||
metadata: | ||
name: awsrequiredtags | ||
spec: | ||
crd: | ||
spec: | ||
names: | ||
kind: AwsRequiredTags | ||
validation: | ||
# Schema for the `parameters` field | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
tags: | ||
type: array | ||
items: | ||
type: string | ||
targets: | ||
- target: admission.k8s.gatekeeper.sh | ||
rego: | | ||
package awsrequiredtags | ||
import future.keywords.every | ||
violation[{"msg": msg}] { | ||
endswith(input.review.kind.group, "s3.aws.crossplane.io") | ||
not startswith(input.review.kind.kind, "ProviderConfig") | ||
not input.review.object.spec.forProvider.tags | ||
msg := sprintf("Attempting to provision a resource without tags, the following tags are required '%v'", [input.parameters.tags]) | ||
} | ||
violation[{"msg": msg}] { | ||
some requested_tag in input.parameters.tags | ||
every i in input.review.object.spec.forProvider.tags { | ||
requested_tag != i.key | ||
} | ||
msg := sprintf("Attempting to provision a resource with the following tags '%v', one or more of the required tags '%v' is missing", [input.review.object.spec.forProvider.tags, input.parameters.tags]) | ||
} |
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
9 changes: 9 additions & 0 deletions
9
examples/upbound-aws-provider/composite-resources/s3-irsa/helm-chart/values.yaml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Default values for checkout. | ||
# This is a YAML-formatted file. | ||
# Declare variables to be passed into your templates. | ||
|
||
s3irsa: | ||
enabled: true | ||
tags: | ||
owner: devops | ||
environment: production |