Skip to content

chore(tests): use valid ARN formats in test fixtures to comply with cfn-lint#3916

Merged
roger-zhangg merged 1 commit intoaws:developfrom
roger-zhangg:fix/cfn-lint-fixture-arn-values
Apr 22, 2026
Merged

chore(tests): use valid ARN formats in test fixtures to comply with cfn-lint#3916
roger-zhangg merged 1 commit intoaws:developfrom
roger-zhangg:fix/cfn-lint-fixture-arn-values

Conversation

@roger-zhangg
Copy link
Copy Markdown
Member

Summary

Follow-up to #3915. Fix the underlying cause instead of suppressing the checks: update test fixture inputs to use valid AWS ARN formats, regenerate outputs, then remove the temporary ignore rules from .cfnlintrc.yaml.

Background

cfn-lint 1.49.0 (aws-cloudformation/cfn-lint#4442) expanded format coverage, adding ARN pattern validation for ACM certificates, IAM roles, KMS keys, and cross-resource Ref/GetAtt checking. The fix rules originally added in #3915 blanket-ignored these checks across all test fixtures, which also hides any future real issues. This PR fixes the fixtures properly.

Changes

Input YAML updates — replace placeholder values with valid-format ARNs:

Resource type Old value New value
ACM Certificate my-api-cert-arn arn:aws:acm:us-east-1:123456789012:certificate/my-api-cert
ACM Certificate cert-arn-in-us-east-1 arn:aws:acm:us-east-1:123456789012:certificate/abc123
ACM Certificate another-api-arn arn:aws:acm:us-east-1:123456789012:certificate/another-api-cert
ACM Certificate arn::cert::abc arn:aws:acm:us-east-1:123456789012:certificate/abc
IAM Role some-arn, some-role-arn, SomeRoleArn arn:aws:iam::123456789012:role/...
IAM Role my-ddb-role, my-lambda-role arn:aws:iam::123456789012:role/my-ddb-role, .../my-lambda-role
KMS Key thisIsaKey, some-kms-arn arn:aws:kms:us-east-1:123456789012:key/...
KMS (Fn::Sub) arn:${AWS::Partition}:key:key arn:${AWS::Partition}:kms:us-east-1:123456789012:key/my-key

E1041 fix in function_with_kmskeyarn.yaml: changed KmsKeyArn: !Ref myKey to KmsKeyArn: !GetAtt myKey.Arn. Ref on an AWS::KMS::Key returns a Key ID (UUID), not an ARN — per the Lambda CreateFunction API, KMSKeyArn requires an ARN. This change makes the template actually correct.

Output JSON regeneration: 12 testcases with content-hashed logical IDs (API Gateway deployments, KMS ARN-dependent outputs) were regenerated by replaying the transformer. All 2117 transform tests pass.

.cfnlintrc.yaml: removed E1041, E1156, E1157, E1159, W1031 from ignore_checks (added in #3915).

Testing

  • All 2117 transform tests pass locally
  • cfn-lint 1.49.3 --format parseable produces 0 errors against the generated templates

…fn-lint

cfn-lint 1.49.x added stricter format validation for AWS resource ARN
properties (E1156/E1157/E1159, E1041, W1031). Update test fixtures to
use ARNs that conform to the expected patterns, so cfn-lint runs cleanly
without needing to suppress these rules.

Changes:
- Replace placeholder values with valid-format ARN strings in test inputs:
  - ACM certificates: 'my-api-cert-arn', 'cert-arn-in-us-east-1',
    'another-api-arn', 'arn::cert::abc' -> arn:aws:acm:us-east-1:123456789012:certificate/...
  - IAM roles: 'some-arn', 'some-role-arn', 'SomeRoleArn', 'my-ddb-role',
    'my-lambda-role' -> arn:aws:iam::123456789012:role/...
  - KMS keys: 'thisIsaKey', 'some-kms-arn' -> arn:aws:kms:us-east-1:123456789012:key/...
  - Fn::Sub: 'arn:${AWS::Partition}:key:key' -> arn:${AWS::Partition}:kms:us-east-1:123456789012:key/my-key
- In function_with_kmskeyarn.yaml, change KmsKeyArn value from Ref: myKey
  (returns Key ID) to Fn::GetAtt: [myKey, Arn] (correct ARN reference)
- Regenerate corresponding output JSON fixtures
- Remove the E1041/E1156/E1157/E1159/W1031 rules from .cfnlintrc.yaml
  ignore list (added temporarily in aws#3915)
@roger-zhangg roger-zhangg requested a review from a team as a code owner April 22, 2026 21:01
@roger-zhangg roger-zhangg merged commit 6b6e8ce into aws:develop Apr 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants