hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.74k stars 9.1k forks source link

[New Resource]: KMS resource for signing #27312

Open KyleKotowick opened 1 year ago

KyleKotowick commented 1 year ago

Description

The AWS provider currently offers a resource (and data source) for using a KMS key to encrypt plaintext into ciphertext (aws_kms_ciphertext), i.e. a resource that uses the https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html operation.

What would be equally useful is a resource and data source that uses a KMS key to sign a message, i.e. a resource / data source that uses the https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html operation.

Specifically, this would allow us to build a KMS-based certificate authority without needing to store any secrets (private keys) in the Terraform state.

This operation is supported in the AWS Go SDK v2.

Requested Resource(s) and/or Data Source(s)

Resource:

Data source:

Potential Terraform Configuration

resource "aws_kms_key" "mykey" {
  description = "test key"
  is_enabled  = true
}

resource "aws_kms_signature" "signature" {
  key_id = aws_kms_key.mykey.key_id
  signing_algorithm = "RSASSA_PSS_SHA_256"
  message_type = "RAW"
  message = <<EOF
{
  "client_id": "e587dbae22222f55da22",
  "client_secret": "8289575d00000ace55e1815ec13673955721b8a5"
}
EOF
}

data "aws_kms_signature" "signature" {
  key_id = aws_kms_key.mykey.key_id
  signing_algorithm = "RSASSA_PSS_SHA_256"
  message_type = "RAW"
  message = <<EOF
{
  "client_id": "e587dbae22222f55da22",
  "client_secret": "8289575d00000ace55e1815ec13673955721b8a5"
}
EOF
}


### References

_No response_

### Would you like to implement a fix?

No
github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

maxdec commented 1 year ago

I think you meant https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html

KyleKotowick commented 1 year ago

I think you meant https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html

Fixed, thank you.