Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Kinesis Stream Consumer resource and data source (third time) #17149

Merged
merged 4 commits into from
Mar 18, 2021

Conversation

anthonyroach
Copy link
Contributor

@anthonyroach anthonyroach commented Jan 16, 2021

This adds support for AWS Kinesis Stream Consumers, that allow for a dedicated consumer using enhanced fan-out.

Changes proposed in this pull request:

Adds aws_kinesis_stream_consumer as new resource
Adds aws_kinesis_stream_consumer as new data source

It is based on the original contribution of #10487

Changes on top of #10487:

  • rebased onto master, and squashed
  • added warning on resource removal on not found during read
  • set the resource id immediately after creation
  • fixed import id syntax to match the documentation
  • added an import test
  • removed Optional from arn output in schema

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #7611

Release note for CHANGELOG:

FEATURES:
New Data Source: aws_kinesis_stream_consumer
New Resource: aws_kinesis_stream_consumer

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccAWSKinesisStreamConsumer'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSKinesisStreamConsumer -timeout 120m
=== RUN   TestAccAWSKinesisStreamConsumerDataSource_basic
=== PAUSE TestAccAWSKinesisStreamConsumerDataSource_basic
=== RUN   TestAccAWSKinesisStreamConsumer_basic
=== PAUSE TestAccAWSKinesisStreamConsumer_basic
=== RUN   TestAccAWSKinesisStreamConsumer_createMultipleConcurrentStreamConsumers
=== PAUSE TestAccAWSKinesisStreamConsumer_createMultipleConcurrentStreamConsumers
=== CONT  TestAccAWSKinesisStreamConsumerDataSource_basic
=== CONT  TestAccAWSKinesisStreamConsumer_basic
=== CONT  TestAccAWSKinesisStreamConsumer_createMultipleConcurrentStreamConsumers
--- PASS: TestAccAWSKinesisStreamConsumer_createMultipleConcurrentStreamConsumers (75.59s)
--- PASS: TestAccAWSKinesisStreamConsumerDataSource_basic (76.44s)
--- PASS: TestAccAWSKinesisStreamConsumer_basic (77.05s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	77.125s

@anthonyroach anthonyroach requested a review from a team as a code owner January 16, 2021 22:55
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/kinesis Issues and PRs that pertain to the kinesis service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 16, 2021
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jan 16, 2021
@anthonyroach
Copy link
Contributor Author

anthonyroach commented Jan 16, 2021

I hope this can get merged soon. Issue #7611 that requested this change is almost two years old now, and the original PR #6565 is even older. I only made very minor changes to the previous PR #10487 to satisfy the contribution requirements and fix a bug in the import implementation.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome @anthonyroach 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@anthonyroach anthonyroach changed the title add aws_kinesis_stream_consumer resource and data source Adds Kinesis Stream Consumer resource and data source (third time) Jan 17, 2021
Base automatically changed from master to main January 23, 2021 01:00
@anGie44 anGie44 self-assigned this Mar 17, 2021
@anGie44 anGie44 removed the needs-triage Waiting for first response or review from a maintainer. label Mar 18, 2021
@anGie44
Copy link
Contributor

anGie44 commented Mar 18, 2021

Hi @anthonyroach, thank you for this PR! Since it extends #10487, I've merged in commits from that PR into here so that the contributor gets credit for their work, nevertheless your commits should appear unchanged (if you have any questions please reach out!). Quick note, to get this highly requested PR into an upcoming release, I'm going to provide a review and may make some changes to bring the work inline with current provider conventions if needed.

@anthonyroach
Copy link
Contributor Author

Hi @anthonyroach, thank you for this PR! Since it extends #10487, I've merged in commits from that PR into here so that the contributor gets credit for their work, nevertheless your commits should appear unchanged (if you have any questions please reach out!). Quick note, to get this highly requested PR into an upcoming release, I'm going to provide a review and may make some changes to bring the work inline with current provider conventions if needed.

Thanks. Unfortunately merging the branches seems to have broken some things due to conflicting changes. I suppose in retrospect I should have not squashed the change like I did. Not sure what the best way to fix this is.

@anGie44
Copy link
Contributor

anGie44 commented Mar 18, 2021

Ohh @anthonyroach are you referring to the This branch cannot be rebased due to conflicts message or the failing CI check, the latter of which seems to be coming from the main branch. I'll take a look at the rebase related conflicts and see if it can be easily updated 👍

@anthonyroach
Copy link
Contributor Author

anthonyroach commented Mar 18, 2021

Ohh @anthonyroach are you referring to the This branch cannot be rebased due to conflicts message or the failing CI check, the latter of which seems to be coming from the main branch. I'll take a look at the rebase related conflicts and see if it can be easily updated

Yeah the failing CI checks, but looking more closely those aren't lines the original author or I changed, and I'm not able to reproduce the failure locally:

aws/resource_aws_ami.go:245:4: duplicate key "owner_id" in map literal
	previous key at aws/resource_aws_ami.go:189:4
aws/resource_aws_ami_copy.go:217:4: duplicate key "owner_id" in map literal
	previous key at aws/resource_aws_ami_copy.go:158:4
aws/resource_aws_ami_from_instance.go:204:4: duplicate key "owner_id" in map literal
	previous key at aws/resource_aws_ami_from_instance.go:145:4
Error: Process completed with exit code 2.

@anthonyroach
Copy link
Contributor Author

Oh, I see, the failures are coming from main which this branch is being rebased onto as part of the CI checks. Makes sense.

@anGie44 anGie44 force-pushed the f-kinesis_stream_consumer branch 2 times, most recently from 045c510 to f4d9746 Compare March 18, 2021 01:32
Anthony Roach and others added 3 commits March 18, 2021 02:43
Adapted from original commits from @rockycore at
yomagroup:feature/kinesis-stream-consumer.

Changes on top of the original commits:

* rebased onto master, and squashed
* added warning resource removal on not found during read
* set the resource id immediately after creation
* fixed import id syntax to match the documentation
* added an import test
* removed Optional from arn output in schema
cn := d.Get("name").(string)
sa := d.Get("stream_arn").(string)

state, err := readKinesisStreamConsumerState(conn, cn, sa)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can expand the search functionality (by name and/or arn, as well as neither) by using the ListStreamConsumers API method, so I'll update here w/usage

func TestAccAWSKinesisStreamConsumerDataSource_basic(t *testing.T) {
var stream kinesis.StreamDescription
var consumer kinesis.ConsumerDescription
config := createAccKinesisStreamConsumerConfig()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting usage! just for maintainability, and current recommendations, we should however prefer to reference functions that are more explicit when defining resources and/or data-sources. I'll update these tests with updated examples.

Delete: schema.DefaultTimeout(120 * time.Minute),
},

Importer: &schema.ResourceImporter{
Copy link
Contributor

@anGie44 anGie44 Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the DescribeStreamConsumer and Deregister API methods support searching by ARN, we can set the ID with the determined ARN for easier lookup throughout 👍

Read: resourceAwsKinesisStreamConsumerRead,
Delete: resourceAwsKinesisStreamConsumerDelete,

Timeouts: &schema.ResourceTimeout{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally, we prefer to handle timeout settings within the status and waiter functions on create/delete in place of operator-defined timeouts

d.Set("arn", arn)

// No error, wait for ACTIVE state
stateConf := &resource.StateChangeConf{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great! just moving this out into the service package

cn := d.Get("name").(string)
sa := d.Get("stream_arn").(string)

state, err := readKinesisStreamConsumerState(conn, cn, sa)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we'll have the ARN stored as the ID, resource lookup will be updated to use that attribute and will be relocated in the service package as well

@anGie44 anGie44 force-pushed the f-kinesis_stream_consumer branch from f4d9746 to 897d5a8 Compare March 18, 2021 06:55
@ghost ghost added size/XXL Managed by automation to categorize the size of a PR. and removed size/XL Managed by automation to categorize the size of a PR. labels Mar 18, 2021
@anGie44 anGie44 force-pushed the f-kinesis_stream_consumer branch from 897d5a8 to 46a1b6f Compare March 18, 2021 07:01
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. size/XXL Managed by automation to categorize the size of a PR. and removed size/XXL Managed by automation to categorize the size of a PR. size/XL Managed by automation to categorize the size of a PR. labels Mar 18, 2021
@anGie44 anGie44 added this to the v3.33.0 milestone Mar 18, 2021
@anGie44 anGie44 force-pushed the f-kinesis_stream_consumer branch from 46a1b6f to 48bf260 Compare March 18, 2021 07:08
Copy link
Contributor

@anGie44 anGie44 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @anthonyroach 🚀 !

Output of acceptance tests (commercial):

--- PASS: TestAccAWSKinesisStreamConsumer_disappears (80.92s)
--- PASS: TestAccAWSKinesisStreamConsumerDataSource_Arn (83.21s)
--- PASS: TestAccAWSKinesisStreamConsumerDataSource_Name (83.12s)
--- PASS: TestAccAWSKinesisStreamConsumer_basic (84.88s)
--- PASS: TestAccAWSKinesisStream_shardLevelMetrics (129.77s)
--- PASS: TestAccAWSKinesisStreamConsumerDataSource_basic (135.51s)
--- PASS: TestAccAWSKinesisStream_encryptionWithoutKmsKeyThrowsError (149.59s)
--- PASS: TestAccAWSKinesisStream_retentionPeriod (150.75s)
--- PASS: TestAccAWSKinesisStream_shardCount (163.92s)
--- PASS: TestAccAWSKinesisStream_basic (171.69s)
--- PASS: TestAccAWSKinesisStream_enforceConsumerDeletion (173.03s)
--- PASS: TestAccAWSKinesisStream_UpdateKmsKeyId (174.11s)
--- PASS: TestAccAWSKinesisStreamConsumer_MaxConcurrentConsumers (178.19s)
--- PASS: TestAccAWSKinesisStream_encryption (183.20s)
--- PASS: TestAccAWSKinesisStream_createMultipleConcurrentStreams (192.18s)
--- PASS: TestAccAWSKinesisStreamConsumer_ExceedMaxConcurrentConsumers (200.52s)
--- PASS: TestAccAWSKinesisStream_Tags (217.47s)
--- PASS: TestAccAWSKinesisStreamDataSource_basic (224.17s)

Gov cloud:

--- PASS: TestAccAWSKinesisStreamConsumerDataSource_Name (74.85s)
--- PASS: TestAccAWSKinesisStreamConsumer_MaxConcurrentConsumers (81.56s)
--- PASS: TestAccAWSKinesisStreamConsumerDataSource_basic (82.01s)
--- PASS: TestAccAWSKinesisStream_encryptionWithoutKmsKeyThrowsError (83.29s)
--- PASS: TestAccAWSKinesisStream_basic (85.14s)
--- PASS: TestAccAWSKinesisStreamConsumerDataSource_Arn (90.26s)
--- PASS: TestAccAWSKinesisStreamConsumer_disappears (91.88s)
--- PASS: TestAccAWSKinesisStreamConsumer_ExceedMaxConcurrentConsumers (98.85s)
--- PASS: TestAccAWSKinesisStream_retentionPeriod (99.19s)
--- PASS: TestAccAWSKinesisStreamConsumer_basic (103.76s)
--- PASS: TestAccAWSKinesisStreamDataSource_basic (105.31s)
--- PASS: TestAccAWSKinesisStream_shardCount (114.16s)
--- PASS: TestAccAWSKinesisStream_shardLevelMetrics (119.68s)
--- PASS: TestAccAWSKinesisStream_createMultipleConcurrentStreams (120.71s)
--- PASS: TestAccAWSKinesisStream_enforceConsumerDeletion (49.79s)
--- PASS: TestAccAWSKinesisStream_encryption (137.24s)
--- PASS: TestAccAWSKinesisStream_Tags (94.82s)
--- PASS: TestAccAWSKinesisStream_UpdateKmsKeyId (94.31s)

Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validateArn,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add additional validation here with the method validateArn

@anGie44 anGie44 merged commit 436f62c into hashicorp:main Mar 18, 2021
@ghost
Copy link

ghost commented Mar 18, 2021

This has been released in version 3.33.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 for triage. Thanks!

@anthonyroach
Copy link
Contributor Author

Awesome! Thanks @anGie44

@ghost
Copy link

ghost commented Apr 17, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. provider Pertains to the provider itself, rather than any interaction with AWS. service/kinesis Issues and PRs that pertain to the kinesis service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kinesis Stream Consumer
3 participants