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

r/aws_cloudwatch_metric_stream: New resource #19429

Merged
merged 14 commits into from
May 19, 2021
Merged

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented May 18, 2021

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 #18870 (supercedes)
Closes #18525

Output from acceptance testing (us-west-2):

--- PASS: TestAccAWSCloudWatchMetricStream_noName (21.20s)
--- PASS: TestAccAWSCloudWatchMetricStream_excludeFilters (21.32s)
--- PASS: TestAccAWSCloudWatchMetricStream_includeFilters (21.39s)
--- PASS: TestAccAWSCloudWatchMetricStream_namePrefix (21.39s)
--- PASS: TestAccAWSCloudWatchMetricStream_tags (21.39s)
--- PASS: TestAccAWSCloudWatchMetricStream_update (84.21s)
--- PASS: TestAccAWSCloudWatchMetricStream_basic (86.79s)
--- PASS: TestAccAWSCloudWatchMetricStream_updateName (157.46s)

Output from acceptance testing (GovCloud):

There does not seem to be support on GovCloud but rather than fail, tests timeout...
=== CONT  TestAccAWSCloudWatchMetricStream_basic
    provider_test.go:1092: skipping test for aws-us-gov/us-gov-west-1: Error running apply: exit status 1
        
        Error: putting metric_stream failed: RequestCanceled: request context canceled
        caused by: context deadline exceeded
        
          with aws_cloudwatch_metric_stream.test,
          on terraform_plugin_test.tf line 4, in resource "aws_cloudwatch_metric_stream" "test":
           4: resource "aws_cloudwatch_metric_stream" "test" {


--- SKIP: TestAccAWSCloudWatchMetricStream_namePrefix (70.36s)
--- SKIP: TestAccAWSCloudWatchMetricStream_update (70.46s)
--- SKIP: TestAccAWSCloudWatchMetricStream_noName (70.48s)
--- SKIP: TestAccAWSCloudWatchMetricStream_excludeFilters (70.52s)
--- SKIP: TestAccAWSCloudWatchMetricStream_tags (70.56s)
--- SKIP: TestAccAWSCloudWatchMetricStream_includeFilters (70.57s)
--- SKIP: TestAccAWSCloudWatchMetricStream_updateName (119.56s)
--- SKIP: TestAccAWSCloudWatchMetricStream_basic (124.57s)

@YakDriver YakDriver requested a review from a team as a code owner May 18, 2021 19:35
@ghost ghost added size/XXL 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/cloudwatch Issues and PRs that pertain to the cloudwatch service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels May 18, 2021
Comment on lines 120 to 127
var name string
if v, ok := d.GetOk("name"); ok {
name = v.(string)
} else if v, ok := d.GetOk("name_prefix"); ok {
name = resource.PrefixedUniqueId(v.(string))
} else {
name = resource.UniqueId()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should follow the recommended Resource Name Generation Support pattern.

log.Printf("[DEBUG] Putting CloudWatch MetricStream: %#v", params)
_, err := conn.PutMetricStreamWithContext(ctx, &params)
if err != nil {
return diag.FromErr(fmt.Errorf("Putting metric_stream failed: %s", err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return diag.FromErr(fmt.Errorf("Putting metric_stream failed: %s", err))
return diag.FromErr(fmt.Errorf("putting metric_stream failed: %w", err))

}

if err != nil {
return diag.FromErr(fmt.Errorf("Reading metric_stream failed: %s", err))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return diag.FromErr(fmt.Errorf("Reading metric_stream failed: %s", err))
return diag.FromErr(fmt.Errorf("reading metric_stream failed: %w", err))

@YakDriver
Copy link
Member Author

YakDriver commented May 18, 2021

Tags are a little strange for CloudWatch Metric Stream.

  1. cloudwatch.TagResource() does not support tagging a metric stream. According to the docs, "Currently, the only CloudWatch resources that can be tagged are alarms and Contributor Insights rules." Presumably, this means "tagged with TagResource()."
  2. cloudwatch.PutMetricStreamInput{} does have a Tags field.
  3. cloudwatch.GetMetricStreamOutput{} does not have a Tags field.

So, tags can go in, but then you can never, have-I-ever see them again. 🤔

@gcacace
Copy link
Contributor

gcacace commented May 18, 2021

Tags are a little strange for CloudWatch Metric Stream.

  1. cloudwatch.TagResource() does not support tagging a metric stream. According to the docs, "Currently, the only CloudWatch resources that can be tagged are alarms and Contributor Insights rules." Presumably, this means "tagged with TagResource()."
  2. cloudwatch.PutMetricStreamInput{} does have a Tags field.
  3. cloudwatch.GetMetricStreamOutput{} does not have a Tags field.

So, tags can go in, but then you can never, have-I-ever see them again. 🤔

https://docs.aws.amazon.com/sdk-for-go/api/service/cloudwatch/#CloudWatch.ListTagsForResource

This should give you back tags for metric streams (an integration test should demonstrate that). I suspect the API documentation for both TagResource and ListResourceTags need to be updated.

@magnetikonline
Copy link
Contributor

Great work team - keen to see this land. 👍

@YakDriver
Copy link
Member Author

YakDriver commented May 19, 2021

This should give you back tags for metric streams (an integration test should demonstrate that). I suspect the API documentation for both TagResource and ListResourceTags need to be updated.

Unfortunately, it does not. You are correct! I was using the resource ID rather than the ARN to get the tags.

But, running into an issue with GovCloud. It doesn't fail, just times out.

@YakDriver YakDriver added this to the v3.41.0 milestone May 19, 2021
@YakDriver YakDriver merged commit 9e042e9 into main May 19, 2021
@YakDriver YakDriver deleted the f-cloudwatch_metric_stream branch May 19, 2021 01:55
@YakDriver YakDriver modified the milestones: v3.41.0, v3.42.0 May 19, 2021
github-actions bot pushed a commit that referenced this pull request May 19, 2021
@ghost
Copy link

ghost commented May 20, 2021

This has been released in version 3.42.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!

ismith added a commit to honeycombio/terraform-aws-honeycomb-cloudwatch-metric-stream that referenced this pull request May 21, 2021
…am resource

See: hashicorp/terraform-provider-aws#19429
(which superseded
hashicorp/terraform-provider-aws#18870).  Which
means we can remove all the clunky run-your-own-forked-provider junk.
Yay!
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 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/cloudwatch Issues and PRs that pertain to the cloudwatch service. size/XXL 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.

Amazon CloudWatch Metric Streams
4 participants