diff --git a/.changelog/35453.txt b/.changelog/35453.txt new file mode 100644 index 00000000000..1c01f61ae04 --- /dev/null +++ b/.changelog/35453.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +aws_prometheus_scraper: Add `role_arn` attribute +``` diff --git a/internal/service/amp/scraper.go b/internal/service/amp/scraper.go index 5224c93b6e2..df5e6e57177 100644 --- a/internal/service/amp/scraper.go +++ b/internal/service/amp/scraper.go @@ -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{ @@ -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)...) @@ -316,6 +320,7 @@ func (r *scraperResource) Read(ctx context.Context, req resource.ReadRequest, re AMP: fwtypes.NewListNestedObjectValueOfPtr(ctx, &DestinationData), }) } + data.RoleARN = flex.StringToFramework(ctx, scraper.RoleArn) if v, ok := scraper.ScrapeConfiguration.(*awstypes.ScrapeConfigurationMemberConfigurationBlob); ok { data.ScrapeConfiguration = flex.StringValueToFramework(ctx, string(v.Value)) } @@ -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"` diff --git a/internal/service/amp/scraper_test.go b/internal/service/amp/scraper_test.go index 1db2fdd3309..538c61e8029 100644 --- a/internal/service/amp/scraper_test.go +++ b/internal/service/amp/scraper_test.go @@ -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"), diff --git a/website/docs/r/prometheus_scraper.html.markdown b/website/docs/r/prometheus_scraper.html.markdown index 4bc32f6b15d..e154495f2c4 100644 --- a/website/docs/r/prometheus_scraper.html.markdown +++ b/website/docs/r/prometheus_scraper.html.markdown @@ -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