Skip to content

Commit

Permalink
Merge pull request #35453 from bonclay7/f-update-prometheus-scraper-a…
Browse files Browse the repository at this point in the history
…ttributes

Export Prometheus scraper role ARN
  • Loading branch information
ewbankkit authored Jan 24, 2024
2 parents eec801b + f298ee3 commit 387fe4b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/35453.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
aws_prometheus_scraper: Add `role_arn` attribute
```
6 changes: 6 additions & 0 deletions internal/service/amp/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func (r *scraperResource) Schema(ctx context.Context, req resource.SchemaRequest
},
names.AttrARN: framework.ARNAttributeComputedOnly(),
names.AttrID: framework.IDAttribute(),
"role_arn": schema.StringAttribute{
Computed: true,
},
"scrape_configuration": schema.StringAttribute{
Required: true,
PlanModifiers: []planmodifier.String{
Expand Down Expand Up @@ -273,6 +276,7 @@ func (r *scraperResource) Create(ctx context.Context, req resource.CreateRequest

// Set values for unknowns after creation is complete.
sourceData.EKS = fwtypes.NewListNestedObjectValueOfPtr(ctx, eksSourceData)
data.RoleARN = flex.StringToFramework(ctx, scraper.RoleArn)
data.Source = fwtypes.NewListNestedObjectValueOfPtr(ctx, sourceData)

resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
Expand Down Expand Up @@ -316,6 +320,7 @@ func (r *scraperResource) Read(ctx context.Context, req resource.ReadRequest, re
AMP: fwtypes.NewListNestedObjectValueOfPtr(ctx, &ampDestinationData),
})
}
data.RoleARN = flex.StringToFramework(ctx, scraper.RoleArn)
if v, ok := scraper.ScrapeConfiguration.(*awstypes.ScrapeConfigurationMemberConfigurationBlob); ok {
data.ScrapeConfiguration = flex.StringValueToFramework(ctx, string(v.Value))
}
Expand Down Expand Up @@ -392,6 +397,7 @@ type scraperResourceModel struct {
ARN types.String `tfsdk:"arn"`
Destination fwtypes.ListNestedObjectValueOf[scraperDestinationModel] `tfsdk:"destination"`
ID types.String `tfsdk:"id"`
RoleARN types.String `tfsdk:"role_arn"`
ScrapeConfiguration types.String `tfsdk:"scrape_configuration"`
Source fwtypes.ListNestedObjectValueOf[scraperSourceModel] `tfsdk:"source"`
Tags types.Map `tfsdk:"tags"`
Expand Down
1 change: 1 addition & 0 deletions internal/service/amp/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func TestAccAMPScraper_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "arn"),
resource.TestCheckResourceAttr(resourceName, "destination.#", "1"),
resource.TestCheckResourceAttr(resourceName, "destination.0.amp.#", "1"),
resource.TestCheckResourceAttrSet(resourceName, "role_arn"),
resource.TestCheckResourceAttrSet(resourceName, "scrape_configuration"),
resource.TestCheckResourceAttr(resourceName, "source.#", "1"),
resource.TestCheckResourceAttr(resourceName, "source.0.eks.#", "1"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/prometheus_scraper.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ The following arguments are optional:
This resource exports the following attributes in addition to the arguments above:

* `arn` - The Amazon Resource Name (ARN) of the new scraper.
* `role_arn` - The Amazon Resource Name (ARN) of the IAM role that provides permissions for the scraper to discover, collect, and produce metrics
* `status` - Status of the scraper. One of ACTIVE, CREATING, DELETING, CREATION_FAILED, DELETION_FAILED

## Timeouts
Expand Down

0 comments on commit 387fe4b

Please sign in to comment.