Skip to content

Commit c875b6b

Browse files
Terminal code mappings for VPC resource (#64)
Issue #, if available: [1362](aws-controllers-k8s/community#1362) Description of changes: - Mapped terminal codes for **VPC** resource. - Added integration tests for the mapped terminal codes. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent e23b931 commit c875b6b

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-07-22T20:12:33Z"
2+
build_date: "2022-07-27T20:49:18Z"
33
build_hash: 87477ae8ca8ac6ddb8c565bbd910cc7e30f55ed0
4-
go_version: go1.17.5
4+
go_version: go1.18.3
55
version: v0.19.3
66
api_directory_checksum: 8c35bdcab21768638dfaa277896e05fdd8a11969
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: e6b4abcc020960d535a8a1022c087323ea2c40a6
10+
file_checksum: 408f1670239ae06ac55ce0b26cb642eccfe68915
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ resources:
429429
404:
430430
code: InvalidVpcID.NotFound
431431
terminal_codes:
432-
- InvalidParameterCombination
432+
- InvalidParameterValue
433433
fields:
434434
EnableDNSSupport:
435435
from:

generator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ resources:
429429
404:
430430
code: InvalidVpcID.NotFound
431431
terminal_codes:
432-
- InvalidParameterCombination
432+
- InvalidParameterValue
433433
fields:
434434
EnableDNSSupport:
435435
from:

pkg/resource/vpc/sdk.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/tests/test_vpc.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,35 @@ def test_enable_attributes(self, ec2_client):
155155

156156
# Check VPC no longer exists in AWS
157157
ec2_validator.assert_vpc(resource_id, exists=False)
158+
159+
def test_terminal_condition_invalid_parameter_value(self):
160+
resource_name = random_suffix_name("vpc-ack-fail", 24)
161+
replacements = REPLACEMENT_VALUES.copy()
162+
replacements["VPC_NAME"] = resource_name
163+
replacements["CIDR_BLOCK"] = "InvalidValue"
164+
165+
# Load VPC CR
166+
resource_data = load_ec2_resource(
167+
"vpc",
168+
additional_replacements=replacements,
169+
)
170+
logging.debug(resource_data)
171+
172+
# Create k8s resource
173+
ref = k8s.CustomResourceReference(
174+
CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL,
175+
resource_name, namespace="default",
176+
)
177+
k8s.create_custom_resource(ref, resource_data)
178+
cr = k8s.wait_resource_consumed_by_controller(ref)
179+
180+
assert cr is not None
181+
assert k8s.get_resource_exists(ref)
182+
183+
expected_msg = "InvalidParameterValue: Value (InvalidValue) for parameter cidrBlock is invalid. This is not a valid CIDR block."
184+
terminal_condition = k8s.get_resource_condition(ref, "ACK.Terminal")
185+
# Example condition message:
186+
# An error occurred (InvalidParameterValue) when calling the CreateVpc operation:
187+
# Value (dsfre) for parameter cidrBlock is invalid.
188+
# This is not a valid CIDR block.
189+
assert expected_msg in terminal_condition['message']

0 commit comments

Comments
 (0)