question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Statement IDs (SID) must be alpha-numeric

See original GitHub issue

cfn-lint version: cfn-lint 0.15.0

When creating a AWS::IAM::ManagedPolicy and using the Sid statement, cfn-lint is not detecting an invalidly-formed Sid statement

Please provide as much information as possible:

  • Template linting issues:
    • Please provide a CloudFormation sample that generated the issue.
  ManagedPolicyCodeSuiteKmsKey:
    Type: AWS::IAM::ManagedPolicy
    Condition: CreateCodePipelineRole
    Properties:
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Sid: Allow use of KMS key in Operations Production Account
            Effect: Allow
            Resource: !Sub 'arn:aws:kms::123123123123:key/*'
            Action:
              - "kms:Encrypt"
              - "kms:Decrypt"
              - "kms:ReEncrypt*"
              - "kms:GenerateDataKey*"
              - "kms:DescribeKey"

sid_string

Provides a way to include information about an individual statement. For IAM policies, basic alphanumeric characters (A-Z,a-z,0-9) are the only allowed characters in the Sid value. Other AWS services that support resource policies may have other requirements for the Sid value. For example, some services require this value to be unique within an AWS account, and some services allow additional characters such as spaces in the Sid value.

  • Validate if the issue still exists with the latest version of cfn-lint and/or the latest Spec files I do not know how to install latest version, I just ran pip install

  • Feature request:

    • My CloudFormation template fails to Create or Update because the Sid uses invalid characters, and cfn-lint does not detect that.

**NOTE: I have executed cfn-lint -u and it downloaded updates, but the problem remains.


Below is the output from CloudFormation:

The following resource(s) failed to update: [ManagedPolicyCodeSuiteKmsKey].
--
  | 11:20:11 UTC+1000 | UPDATE_FAILED | AWS::IAM::ManagedPolicy | ManagedPolicyCodeSuiteKmsKey | Statement IDs (SID) must be alpha-numeric. Check that your input satisfies the regular expression [0-9A-Za-z]* (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: a632726a-42d2-11e9-8725-21992a944eb3)

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
felipe1982commented, Mar 11, 2019

Thank you for an awesome tool to use when developing and also for CI. Your issue template helped me create the issue so thanks.

1reaction
kddejongcommented, Jul 28, 2019

It could help if we could only do this generically. Looking at just the extra allowed characters in the SID comment. I’m curious if that is just a service based policy instead of an identity based policy issue. If we know the type of services/resources that allow additional characters we may be able to come up with a rule that switches the REGEX based on the type of resource. The question may be is does every service that allow additional characters follow the same standards of what characters they allow.

The best way I’ve found to do this in the past is to deploy each service and see if they take a space or not. Or will build the construct of a rule that could be used for additional services/resources but just starts with ManagedPolicy as we know that one won’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IAM JSON policy elements: Sid - AWS Documentation
You can provide Sid (statement ID) as an optional identifier for the policy statement. ... In IAM, the Sid value must be unique...
Read more >
What is Sid attribute use for in key policies? - Stack Overflow
The Sid (statement ID) is an optional identifier that you provide for the policy statement. You can assign a Sid value to each...
Read more >
Solving Resource name is non alphanumeric Error in AWS CDK
In order to solve the Resource name is non alphanumeric Error, we have to only provide alphanumeric characters for Logical IDs.
Read more >
sid - SAP Help Portal
The ID must consist of exactly three alphanumeric characters. Only uppercase letters are allowed. The first character must be a letter (not a...
Read more >
Terraform AWS IAM Error — “MalformedPolicyDocument ...
data "aws_iam_policy_document" "codebuild" { statement { sid ... to do whatever it needs to do, as long as you have included the appropriate ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found