首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CloudFormation -无法创建KMS

CloudFormation -无法创建KMS
EN

Stack Overflow用户
提问于 2020-10-16 08:19:45
回答 1查看 2.7K关注 0票数 2

我正在尝试使用Cloudformation创建一个KMS键,不幸的是,我无法创建它。在控制台中,我得到以下错误:

代码语言:javascript
复制
null (Service: Kms, Status Code: 400, Request ID: 156b452d-8ffb-5517-9jbc-a6yh6e3a79, Extended Request ID: null)

我无法理解这一问题的根源。请参阅附件中的模板,我正在使用该模板创建KMS:

代码语言:javascript
复制
AWSTemplateFormatVersion: 2010-09-09
Description: Testing KMS Using CloudFormation
        
Resources:
  KMSEncryption:
    Type: AWS::KMS::Key
    Properties:
      Description: KMS-Key
      KeyPolicy:
        Version: '2012-10-17'
        Id: encryption-key
        EnableKeyRotation: 'True'
        PendingWindowInDays: 7
        Statement:
        - Sid: Enable IAM User Permissions
          Effect: Allow
          Principal:
            AWS:
              Fn::Join:
              - ''
              - - 'arn:aws:iam::'
                - Ref: AWS::AccountId
                - :root
          Action: kms:*
          Resource: '*'
        - Sid: Allow use of the key
          Effect: Allow
          Principal:
            AWS:
              Fn::Join:
              - ''
              - - 'arn:aws:iam::'
                - Ref: AWS::AccountId
                - :role/
                - !Ref KMSLambdaRole
          Action:
          - kms:DescribeKey
          - kms:Encrypt
          - kms:Decrypt
          - kms:ReEncrypt*
          - kms:GenerateDataKey
          - kms:GenerateDataKeyWithoutPlaintext
          Resource: '*'
        - Sid: Allow administration of the key
          Effect: Allow
          Principal:
            AWS: arn:aws:iam::xxxxxxxxx:user/Shiv
          Action:
          - kms:Create*
          - kms:Describe*
          - kms:Enable*
          - kms:List*
          - kms:Put*
          - kms:Update*
          - kms:Revoke*
          - kms:Disable*
          - kms:Get*
          - kms:Delete*
          - kms:ScheduleKeyDeletion
          - kms:CancelKeyDeletion

  EncryptionAlias:
    Type: AWS::KMS::Alias
    Properties:
      AliasName: 'Testing'
      TargetKeyId:
        Ref: KMSEncryption

  KMSLambdaRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: 'TestingKMSAccess'
      AssumeRolePolicyDocument:
        Statement:
        - Action: ['sts:AssumeRole']
          Effect: Allow
          Principal:
            Service: [lambda.amazonaws.com]
      Path: /
      ManagedPolicyArns:
        - arn:aws:iam::aws:policy/ReadOnlyAccess
      Policies:
        - PolicyName: AWSLambdaBasicExecutionRole
          PolicyDocument:
            Version: 2012-10-17
            Statement:
              - Sid: SQS
                Action:
                  - 'sqs:SendMessage'
                  - 'sqs:SendMessageBatch'
                Effect: Allow
                Resource: '*'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-16 08:35:54

您的EnableKeyRotationPendingWindowInDays应该是KeyPolicy之外的

代码语言:javascript
复制
Resources:
  KMSEncryption:
    Type: AWS::KMS::Key
    Properties:
      Description: KMS-Key
      EnableKeyRotation: 'True'
      PendingWindowInDays: 7
      KeyPolicy:
        Version: '2012-10-17'
        Id: encryption-key
      # the rest

请注意,可能还有其他问题还不明显,例如不存在的原则.

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64385434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档