如何使用 Cloudformation 创建 KMS 非对称签名密钥资源?
How to create KMS asymmetric signing key resource with Cloudformation?
我已经在我的模板中尝试了以下资源:
SigningKey:
Type: AWS::KMS::Key
Properties:
Description: "Auth API signing key"
Enabled: true
# Grant all permissions for root account
KeyPolicy:
Version: "2012-10-17"
Id: "key-default-1"
Statement:
-
Sid: "Enable IAM User Permissions"
Effect: "Allow"
Principal:
- AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
Action: "kms:*"
Resource: "*"
EnableKeyRotation: true
KeyUsage: SIGN_VERIFY
但这给出了一个错误:
The operation failed because the KeyUsage value of the CMK is
SIGN_VERIFY. To perform this operation, the KeyUsage value must be
ENCRYPT_DECRYPT.
还不清楚在 docs.
模板中的何处指定密钥类型(例如 RSA_2048
)
根据 AWS CloudFormation,您在 KeySpec
字段中指定了密钥类型。您还可以在文档中查看当前支持的类型。此外,AWS KMS 不支持非对称 CMK 上的自动密钥轮换。对于非对称 CMK,省略 EnableKeyRotation 属性 或将其设置为 false。
上面的文档还有创建非对称 CMK 的示例,您可以参考。
我已经在我的模板中尝试了以下资源:
SigningKey:
Type: AWS::KMS::Key
Properties:
Description: "Auth API signing key"
Enabled: true
# Grant all permissions for root account
KeyPolicy:
Version: "2012-10-17"
Id: "key-default-1"
Statement:
-
Sid: "Enable IAM User Permissions"
Effect: "Allow"
Principal:
- AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
Action: "kms:*"
Resource: "*"
EnableKeyRotation: true
KeyUsage: SIGN_VERIFY
但这给出了一个错误:
The operation failed because the KeyUsage value of the CMK is SIGN_VERIFY. To perform this operation, the KeyUsage value must be ENCRYPT_DECRYPT.
还不清楚在 docs.
模板中的何处指定密钥类型(例如RSA_2048
)
根据 AWS CloudFormation,您在 KeySpec
字段中指定了密钥类型。您还可以在文档中查看当前支持的类型。此外,AWS KMS 不支持非对称 CMK 上的自动密钥轮换。对于非对称 CMK,省略 EnableKeyRotation 属性 或将其设置为 false。
上面的文档还有创建非对称 CMK 的示例,您可以参考。