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

Export Prometheus scraper role ARN #35453

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading