Skip to content

Commit 65853e2

Browse files
Merge main to develop (#4012)
Co-authored-by: aws-sam-cli-bot <46753707+aws-sam-cli-bot@users.noreply.github.com>
1 parent 9ee25fd commit 65853e2

71 files changed

Lines changed: 4890 additions & 16 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.cfnlintrc.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ ignore_templates:
115115
- tests/translator/output/**/function_with_logging_config.json # cfnlint is not updated to recognize the LoggingConfig property
116116
- tests/translator/output/aws-*/*capacity_provider*.json # Ignore Capacity Provider test format in non-aws partitions
117117
- tests/translator/output/**/capacity_provider_managed_resource_tags.json # cfnlint not updated for CapacityProvider mode (Phase 2)
118+
- tests/translator/output/**/webfunction_basic.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
119+
- tests/translator/output/**/webfunction_with_all_properties.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
120+
- tests/translator/output/**/webfunction_multiregion.json # New AWS::Lambda::WebFunction* types cfn-lint does not recognize; DependsOn is intentional (W3005)
121+
- tests/translator/output/**/network_connector_with_compute_types.json # cfn-lint's published AWS::Lambda::NetworkConnector schema enum for AssociatedComputeResourceTypes still lists only MicroVm; the preview WebFunction compute type trips E3030
122+
- tests/translator/output/**/graphqlapi_api_cache.json # pre-existing: fixture uses placeholder ApiCachingBehavior/Type values ('somebehaviour'/'mytype') that a cfn-lint registry-schema update now rejects (E3030); unrelated to this change
123+
- tests/translator/output/**/basic_function.json # W1030: fixture uses Ref for VpcConfig SubnetIds, which cannot match the subnet-id pattern
118124

119125
ignore_checks:
120126
- E2531 # Deprecated runtime; not relevant for transform tests

‎bin/run_cfn_lint.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ set -eux
33

44
VENV=.venv_cfn_lint
55

6+
# cfn-lint requires Python >= 3.10, which this project also requires (see python_requires in setup.py).
7+
# Fail loudly rather than skipping: a silent "exit 0" here would turn the lint gate into a no-op on a
8+
# misconfigured interpreter and report success without checking a single template.
9+
PYTHON_MINOR=$(python3 -c "import sys; print(sys.version_info.minor)")
10+
if [ "$PYTHON_MINOR" -lt 10 ]; then
11+
echo "ERROR: cfn-lint requires Python >= 3.10, but python3 is 3.${PYTHON_MINOR}. Use a supported interpreter." >&2
12+
exit 1
13+
fi
14+
615
# Install to separate venv to avoid circular dependency; cfn-lint depends on samtranslator
716
# See https://github.com/aws/serverless-application-model/issues/1042
817
if [ ! -d "${VENV}" ]; then

‎integration/config/code_key_to_file_map.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
"definitionuri": "swagger1.json",
66
"microvmcodeuri": "microvm_code.zip",
77
"mtlsuri": "MTLSCert.pem",
8-
"templateurl": "template.yaml"
8+
"templateurl": "template.yaml",
9+
"webfunccodeuri": "webfunc_code.zip",
10+
"webfunccodeuri2": "webfunc_code2.zip"
911
}

‎integration/config/file_to_s3_map.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,13 @@
4242
"template.yaml": {
4343
"type": "http",
4444
"uri": ""
45+
},
46+
"webfunc_code.zip": {
47+
"type": "s3",
48+
"uri": ""
49+
},
50+
"webfunc_code2.zip": {
51+
"type": "s3",
52+
"uri": ""
4553
}
4654
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
regions:
22
us-east-1:
33
- CustomDomain
4+
- WebFunction
5+
us-west-2:
6+
- WebFunction
7+
eu-west-1:
8+
- WebFunction
49
Metadata:
510
SamTransformTest: true

‎integration/config/service_names.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
LAMBDA_URL = "LambdaUrl"
3434
LAMBDA_MANAGED_INSTANCES = "LambdaManagedInstances"
3535
MICROVM_IMAGE = "MicrovmImage"
36+
WEB_FUNCTION = "WebFunction"
3637
LAMBDA_ENV_VARS = "LambdaEnvVars"
3738
EVENT_INVOKE_CONFIG = "EventInvokeConfig"
3839
API_KEY = "ApiKey"

‎integration/conftest.py‎

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,32 @@ def _get_all_buckets():
3434
return s3.buckets.all()
3535

3636

37-
def clean_bucket(s3_bucket_name, s3_client):
37+
def empty_versioned_bucket(s3_bucket_name, s3_client):
3838
"""
39-
Empties and deletes the bucket used for the tests
39+
Deletes every object version and delete marker from a bucket. Deleting objects without a VersionId
40+
only adds delete markers on a versioned bucket, so the versions must be removed explicitly, otherwise
41+
the bucket cannot be deleted (and CloudFormation's DeletionPolicy: Delete would leave the stack in
42+
DELETE_FAILED). Works for non-versioned buckets too, where each object has a "null" version.
4043
"""
41-
s3 = boto3.resource("s3")
42-
bucket = s3.Bucket(s3_bucket_name)
43-
object_summary_iterator = bucket.objects.all()
44-
45-
for object_summary in object_summary_iterator:
44+
paginator = s3_client.get_paginator("list_object_versions")
45+
for page in paginator.paginate(Bucket=s3_bucket_name):
46+
to_delete = [
47+
{"Key": item["Key"], "VersionId": item["VersionId"]}
48+
for item in (page.get("Versions", []) + page.get("DeleteMarkers", []))
49+
]
50+
if not to_delete:
51+
continue
4652
try:
47-
s3_client.delete_object(Key=object_summary.key, Bucket=s3_bucket_name)
53+
s3_client.delete_objects(Bucket=s3_bucket_name, Delete={"Objects": to_delete})
4854
except ClientError as e:
49-
LOG.error("Unable to delete object %s from bucket %s", object_summary.key, s3_bucket_name, exc_info=e)
55+
LOG.error("Unable to delete object versions from bucket %s", s3_bucket_name, exc_info=e)
56+
57+
58+
def clean_bucket(s3_bucket_name, s3_client):
59+
"""
60+
Empties and deletes the bucket used for the tests
61+
"""
62+
empty_versioned_bucket(s3_bucket_name, s3_client)
5063
try:
5164
s3_client.delete_bucket(Bucket=s3_bucket_name)
5265
except ClientError as e:
@@ -201,6 +214,16 @@ def delete_companion_stack_once(get_prefix):
201214
if os.environ.get("COMPANION_STACK_NAME"):
202215
return
203216
if not get_prefix:
217+
# PreCreatedS3Bucket has versioning enabled, so CloudFormation cannot delete it while it still holds
218+
# object versions or delete markers — the stack would be left in DELETE_FAILED and leak the bucket.
219+
# Empty all versions first so DeletionPolicy: Delete can succeed.
220+
try:
221+
outputs = get_stack_outputs(get_stack_description(COMPANION_STACK_NAME))
222+
bucket_name = outputs.get("PreCreatedS3Bucket")
223+
if bucket_name:
224+
empty_versioned_bucket(bucket_name, ClientProvider().s3_client)
225+
except botocore.exceptions.ClientError as e:
226+
LOG.error("Unable to empty companion bucket before deleting the companion stack", exc_info=e)
204227
ClientProvider().cfn_client.delete_stack(StackName=COMPANION_STACK_NAME)
205228

206229

446 Bytes
Binary file not shown.
308 Bytes
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
{
3+
"LogicalResourceId": "MyWebFunction",
4+
"ResourceType": "AWS::Lambda::WebFunction"
5+
},
6+
{
7+
"LogicalResourceId": "MyWebFunctionEndpoint",
8+
"ResourceType": "AWS::Lambda::WebFunctionEndpoint"
9+
},
10+
{
11+
"LogicalResourceId": "MyWebFunctionRevision",
12+
"ResourceType": "AWS::Lambda::WebFunctionRevision"
13+
},
14+
{
15+
"LogicalResourceId": "MyWebFunctionRole",
16+
"ResourceType": "AWS::IAM::Role"
17+
}
18+
]

0 commit comments

Comments
 (0)