Skip to content

Commit 4e777bb

Browse files
authored
Gatekeeper upgrade (#208)
* 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 * upgrade deprecated api * PR review fix
1 parent 1a9a993 commit 4e777bb

7 files changed

+67
-96
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
apiVersion: dynamodb.aws.crossplane.io/v1alpha1
1+
apiVersion: dynamodb.aws.upbound.io/v1beta1
22
kind: Table
33
metadata:
4+
annotations:
5+
meta.upbound.io/example-id: dynamodb/v1beta1/globaltable
46
name: sample-table
57
spec:
6-
deletionPolicy: Delete
8+
providerConfigRef:
9+
name: aws-provider-config
710
forProvider:
11+
attribute:
12+
- name: myAttribute
13+
type: S
14+
hashKey: myAttribute
15+
readCapacity: 1
16+
writeCapacity: 1
817
region: eu-west-2
9-
attributeDefinitions:
10-
- attributeName: id
11-
attributeType: S
12-
keySchema:
13-
- attributeName: id
14-
keyType: HASH
15-
billingMode: PROVISIONED
16-
provisionedThroughput:
17-
readCapacityUnits: 1
18-
writeCapacityUnits: 1
1918
tags:
20-
- key: "owner"
21-
value: "finance"
22-
providerConfigRef:
23-
name: aws-provider-config
19+
owner: finance
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
apiVersion: dynamodb.aws.crossplane.io/v1alpha1
1+
apiVersion: dynamodb.aws.upbound.io/v1beta1
22
kind: Table
33
metadata:
4+
annotations:
5+
meta.upbound.io/example-id: dynamodb/v1beta1/globaltable
46
name: failing-table
57
spec:
6-
deletionPolicy: Delete
8+
providerConfigRef:
9+
name: aws-provider-config
710
forProvider:
11+
attribute:
12+
- name: myAttribute
13+
type: S
14+
hashKey: myAttribute
15+
readCapacity: 1
16+
writeCapacity: 1
817
region: us-east-1
9-
attributeDefinitions:
10-
- attributeName: id
11-
attributeType: S
12-
keySchema:
13-
- attributeName: id
14-
keyType: HASH
15-
billingMode: PROVISIONED
16-
provisionedThroughput:
17-
readCapacityUnits: 1
18-
writeCapacityUnits: 1
1918
tags:
20-
- key: "owner"
21-
value: "finance"
22-
23-
providerConfigRef:
24-
name: aws-provider-config
19+
owner: finance

examples/gatekeeper/required-tags/samples/constraint.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
spec:
66
match:
77
kinds:
8-
- apiGroups: ["*"]
9-
kinds: ["*"]
8+
- apiGroups: ["dynamodb.aws.upbound.io"]
9+
kinds: ["Table"]
1010
parameters:
1111
tags: ["owner"]
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
apiVersion: dynamodb.aws.crossplane.io/v1alpha1
1+
apiVersion: dynamodb.aws.upbound.io/v1beta1
22
kind: Table
33
metadata:
4+
annotations:
5+
meta.upbound.io/example-id: dynamodb/v1beta1/globaltable
46
name: dummy-table
57
spec:
6-
deletionPolicy: Delete
8+
providerConfigRef:
9+
name: aws-provider-config
710
forProvider:
11+
attribute:
12+
- name: myAttribute
13+
type: S
14+
hashKey: myAttribute
15+
readCapacity: 1
16+
writeCapacity: 1
817
region: eu-west-2
9-
attributeDefinitions:
10-
- attributeName: id
11-
attributeType: S
12-
keySchema:
13-
- attributeName: id
14-
keyType: HASH
15-
billingMode: PROVISIONED
16-
provisionedThroughput:
17-
readCapacityUnits: 1
18-
writeCapacityUnits: 1
1918
tags:
20-
- key: "aaa"
21-
value: "finance"
22-
providerConfigRef:
23-
name: aws-provider-config
19+
aaa: finance
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
apiVersion: dynamodb.aws.crossplane.io/v1alpha1
1+
apiVersion: dynamodb.aws.upbound.io/v1beta1
22
kind: Table
33
metadata:
4+
annotations:
5+
meta.upbound.io/example-id: dynamodb/v1beta1/globaltable
46
name: dummy-table
57
spec:
6-
deletionPolicy: Delete
7-
forProvider:
8-
region: eu-west-2
9-
attributeDefinitions:
10-
- attributeName: id
11-
attributeType: S
12-
keySchema:
13-
- attributeName: id
14-
keyType: HASH
15-
billingMode: PROVISIONED
16-
provisionedThroughput:
17-
readCapacityUnits: 1
18-
writeCapacityUnits: 1
198
providerConfigRef:
20-
name: aws-provider-config
9+
name: aws-provider-config
10+
forProvider:
11+
attribute:
12+
- name: myAttribute
13+
type: S
14+
hashKey: myAttribute
15+
readCapacity: 1
16+
writeCapacity: 1
17+
region: eu-west-2
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
apiVersion: dynamodb.aws.crossplane.io/v1alpha1
1+
apiVersion: dynamodb.aws.upbound.io/v1beta1
22
kind: Table
33
metadata:
4+
annotations:
5+
meta.upbound.io/example-id: dynamodb/v1beta1/globaltable
46
name: finance-table
57
spec:
6-
deletionPolicy: Delete
8+
providerConfigRef:
9+
name: aws-provider-config
710
forProvider:
11+
attribute:
12+
- name: myAttribute
13+
type: S
14+
hashKey: myAttribute
15+
readCapacity: 1
16+
writeCapacity: 1
817
region: eu-west-2
9-
attributeDefinitions:
10-
- attributeName: id
11-
attributeType: S
12-
keySchema:
13-
- attributeName: id
14-
keyType: HASH
15-
billingMode: PROVISIONED
16-
provisionedThroughput:
17-
readCapacityUnits: 1
18-
writeCapacityUnits: 1
1918
tags:
20-
- key: "owner"
21-
value: "finance"
22-
providerConfigRef:
23-
name: aws-provider-config
19+
owner: finance

examples/gatekeeper/required-tags/template.yaml

+5-14
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ spec:
88
names:
99
kind: AwsRequiredTags
1010
validation:
11-
# Schema for the `parameters` field
1211
openAPIV3Schema:
1312
type: object
1413
properties:
@@ -20,19 +19,11 @@ spec:
2019
- target: admission.k8s.gatekeeper.sh
2120
rego: |
2221
package awsrequiredtags
23-
import future.keywords.every
2422
2523
violation[{"msg": msg}] {
26-
endswith(input.review.kind.group, "aws.crossplane.io")
27-
not startswith(input.review.kind.kind, "ProviderConfig")
28-
not input.review.object.spec.forProvider.tags
29-
msg := sprintf("Attempting to provision a resource without tags, the following tags are required '%v'", [input.parameters.tags])
30-
}
31-
32-
violation[{"msg": msg}] {
33-
some requested_tag in input.parameters.tags
34-
every i in input.review.object.spec.forProvider.tags {
35-
requested_tag != i.key
36-
}
37-
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])
24+
input.review.kind.group == "dynamodb.aws.upbound.io"
25+
some i
26+
required_tag := input.parameters.tags[i]
27+
not input.review.object.spec.forProvider.tags[required_tag]
28+
msg := sprintf("Attempting to provision a resource without the required tag '%v'", [required_tag])
3829
}

0 commit comments

Comments
 (0)