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

[Enhancement]: add attribute `kms_key_id` to data `aws_kinesis_stream` #38791

Closed GuillaumeDesforges closed 4 days ago

GuillaumeDesforges commented 1 month ago

Description

The resource aws_kinesis_stream can use encryption with a KMS key with

resource "aws_kinesis_stream" "this" {
    ...
    encryption_type = "KMS"
    kms_key_id = ...
}

See kms_key_id

However it is not possible to fetch that key ID using the equivalent data source. See https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kinesis_stream#attribute-reference

For example, this makes it impossible to properly define a kms:Decrypt policy to the specific key for a lambda with a trigger from Kinesis.

# Allow lambda to decrypt Kinesis stream data
data "aws_kms_key" "kinesis" {
    key_id = data.kinesis_stream.kms_key_id  # <== NOT POSSIBLE TODAY
}

data "aws_iam_policy_document" "decrypt" {
    statement {
        effect = "Allow"
        actions = [
            "kms:Decrypt",
        ]
        resources = [data.aws_kms_key.kinesis.arn] # <== WHAT I NEED
    }
}

My current workaround is to put the ARN manually, which defeats the purpose of IaC.

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

data.aws_kinesis_stream

Potential Terraform Configuration

# Allow lambda to decrypt Kinesis stream data
data "aws_kms_key" "kinesis" {
    key_id = data.kinesis_stream.kms_key_id  # <== NOT POSSIBLE TODAY
}

data "aws_iam_policy_document" "decrypt" {
    statement {
        effect = "Allow"
        actions = [
            "kms:Decrypt",
        ]
        resources = [data.aws_kms_key.kinesis.arn] # <== WHAT I NEED
    }
}

References

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kinesis_stream

Would you like to implement a fix?

Yes

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 4 days ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

github-actions[bot] commented 2 days ago

This functionality has been released in v5.67.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!