Skip to content

Commit 3e6e86f

Browse files
authored
Add e2e test that adopts bucket created in cloudformation (#149)
Issue [#2248](aws-controllers-k8s/community#2248) Description of changes: This test expects the ACK controller to always ignore AWS tags. It also attempts updating the tags and ensures the AWS tags injected by cloudformation are still ignored. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent b6698d9 commit 3e6e86f

File tree

11 files changed

+227
-11
lines changed

11 files changed

+227
-11
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ack_generate_info:
2-
build_date: "2025-02-06T03:32:53Z"
3-
build_hash: 8762917215d9902b2011a2b0b1b0c776855a683e
4-
go_version: go1.23.5
5-
version: v0.42.0
2+
build_date: "2025-02-17T21:07:14Z"
3+
build_hash: 11e0a33c63d0cfcd43042d8f8d07466fc1814135
4+
go_version: go1.24.0
5+
version: v0.42.0-2-g11e0a33
66
api_directory_checksum: 12d59cc27a5fc11bf285d7735d81240e980b1046
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22.0
55
toolchain go1.22.5
66

77
require (
8-
github.com/aws-controllers-k8s/runtime v0.42.0
8+
github.com/aws-controllers-k8s/runtime v0.43.0
99
github.com/aws/aws-sdk-go v1.49.0
1010
github.com/aws/aws-sdk-go-v2 v1.34.0
1111
github.com/aws/aws-sdk-go-v2/service/s3 v1.74.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/aws-controllers-k8s/runtime v0.42.0 h1:fVb3cOwUtn0ZwTSedapES+Rspb97S8BTxMqXJt6R5uM=
2-
github.com/aws-controllers-k8s/runtime v0.42.0/go.mod h1:Oy0JKvDxZMZ+SVupm4NZVqP00KLIIAMfk93KnOwlt5c=
1+
github.com/aws-controllers-k8s/runtime v0.43.0 h1:mCtMHO0rew84VbqotquvBirnKysbao+y2G3QI8bKZxM=
2+
github.com/aws-controllers-k8s/runtime v0.43.0/go.mod h1:Oy0JKvDxZMZ+SVupm4NZVqP00KLIIAMfk93KnOwlt5c=
33
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
44
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
55
github.com/aws/aws-sdk-go-v2 v1.34.0 h1:9iyL+cjifckRGEVpRKZP3eIxVlL06Qk1Tk13vreaVQU=

pkg/resource/bucket/manager.go

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/bucket/tags.go

Lines changed: 47 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/bootstrap_resources.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from acktest.bootstrapping.iam import Role
2121
from acktest.bootstrapping.s3 import Bucket
2222
from acktest.bootstrapping.sns import Topic
23+
from acktest.bootstrapping.cloudformation import Stack
2324
from e2e import bootstrap_directory
2425

2526
@dataclass
@@ -28,6 +29,7 @@ class BootstrapResources(Resources):
2829
AdoptionBucket: Bucket
2930
ReplicationRole: Role
3031
NotificationTopic: Topic
32+
StackBucket: Stack
3133

3234
_bootstrap_resources = None
3335

test/e2e/replacement_values.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
"ADOPTION_BUCKET_NAME": get_bootstrap_resources().AdoptionBucket.name,
2222
"REPLICATION_BUCKET_NAME": get_bootstrap_resources().ReplicationBucket.name,
2323
"NOTIFICATION_TOPIC_ARN": get_bootstrap_resources().NotificationTopic.arn,
24+
"STACK_BUCKET_NAME": get_bootstrap_resources().StackBucket.template["Resources"]["MyS3Bucket"]["Properties"]["BucketName"],
2425
}

test/e2e/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@38ce32256cc2552ab54e190cc8a8618e93af9e0c
1+
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@a49300708a1a5586fec36fd28a2494d9cb2288ab
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: s3.services.k8s.aws/v1alpha1
2+
kind: Bucket
3+
metadata:
4+
name: $STACK_BUCKET_NAME
5+
annotations:
6+
services.k8s.aws/adoption-policy: $ADOPTION_POLICY
7+
services.k8s.aws/adoption-fields: "$ADOPTION_FIELDS"
8+
services.k8s.aws/deletion-policy: retain

test/e2e/service_bootstrap.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
import json
1818
from pathlib import Path
1919

20+
from acktest.resources import random_suffix_name
2021
from acktest.bootstrapping import Resources, BootstrapFailureException
2122
from acktest.bootstrapping.iam import Role, UserPolicies
2223
from acktest.bootstrapping.s3 import Bucket
2324
from acktest.bootstrapping.sns import Topic
25+
from acktest.bootstrapping.cloudformation import Stack
2426
from e2e import bootstrap_directory
2527
from e2e.bootstrap_resources import BootstrapResources
2628

@@ -62,13 +64,30 @@ def service_bootstrap() -> Resources:
6264
]
6365
})
6466

67+
stack_bucket_name = random_suffix_name("stack-bucket", 24)
68+
template = {
69+
"AWSTemplateFormatVersion": "2010-09-09",
70+
"Resources": {
71+
"MyS3Bucket": {
72+
"Type": "AWS::S3::Bucket",
73+
"Properties": {
74+
"BucketName": stack_bucket_name,
75+
"VersioningConfiguration": {
76+
"Status": "Enabled"
77+
}
78+
}
79+
}
80+
}
81+
}
82+
6583
resources = BootstrapResources(
6684
ReplicationBucket=Bucket("ack-s3-replication", enable_versioning=True),
6785
AdoptionBucket=Bucket("ack-s3-annotation-adoption", enable_versioning=True),
6886
ReplicationRole=Role("ack-s3-replication-role", "s3.amazonaws.com",
6987
user_policies=UserPolicies("ack-s3-replication-policy", [replication_policy])
7088
),
71-
NotificationTopic=Topic("ack-s3-notification", policy=notification_policy)
89+
NotificationTopic=Topic("ack-s3-notification", policy=notification_policy),
90+
StackBucket=Stack(name_prefix=stack_bucket_name, template=template)
7291
)
7392

7493
try:

0 commit comments

Comments
 (0)