Skip to content

Commit 0c11ad5

Browse files
authored
feat: add aws_servicequotas_auto_management_configuration table (#2706)
1 parent 1c48279 commit 0c11ad5

12 files changed

Lines changed: 316 additions & 12 deletions

aws-test/tests/aws_servicequotas_auto_management_configuration/dependencies.txt

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"opt_in_status": "{{ output.opt_in_status.value }}",
4+
"opt_in_type": "{{ output.opt_in_type.value }}",
5+
"opt_in_level": "{{ output.opt_in_level.value }}",
6+
"notification_arn": "{{ output.notification_arn.value }}",
7+
"exclusion_list": {{ output.exclusion_list.value }}
8+
}
9+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select opt_in_status, opt_in_type, opt_in_level, notification_arn, exclusion_list
2+
from aws_servicequotas_auto_management_configuration
3+
where region = '{{ output.resource_aka.value | split:':' | at:3 }}';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
{
3+
"akas": ["{{ output.resource_aka.value }}"],
4+
"title": "Auto Management Configuration"
5+
}
6+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select title, akas
2+
from aws_servicequotas_auto_management_configuration
3+
where region = '{{ output.resource_aka.value | split:':' | at:3 }}';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
variable "resource_name" {
2+
type = string
3+
default = "turbot-test-20200125-create-update"
4+
description = "Name of the resource used throughout the test."
5+
}
6+
7+
variable "aws_profile" {
8+
type = string
9+
default = "default"
10+
description = "AWS credentials profile used for the test. Default is to use the default profile."
11+
}
12+
13+
variable "aws_region" {
14+
type = string
15+
default = "us-east-1"
16+
description = "AWS region used for the test. Does not work with default region in config, so must be defined here."
17+
}
18+
19+
variable "aws_region_alternate" {
20+
type = string
21+
default = "us-east-2"
22+
description = "Alternate AWS region used for tests that require two regions (e.g. DynamoDB global tables)."
23+
}
24+
25+
provider "aws" {
26+
profile = var.aws_profile
27+
region = var.aws_region
28+
}
29+
30+
provider "aws" {
31+
alias = "alternate"
32+
profile = var.aws_profile
33+
region = var.aws_region_alternate
34+
}
35+
36+
data "aws_partition" "current" {}
37+
data "aws_caller_identity" "current" {}
38+
data "aws_region" "primary" {}
39+
data "aws_region" "alternate" {
40+
provider = aws.alternate
41+
}
42+
43+
data "null_data_source" "resource" {
44+
inputs = {
45+
scope = "arn:${data.aws_partition.current.partition}:::${data.aws_caller_identity.current.account_id}"
46+
}
47+
}
48+
49+
resource "null_resource" "auto_management_configuration" {
50+
provisioner "local-exec" {
51+
command = "aws service-quotas get-auto-management-configuration > ${path.cwd}/auto_management_configuration.json"
52+
}
53+
}
54+
55+
data "local_file" "auto_management_configuration" {
56+
depends_on = [null_resource.auto_management_configuration]
57+
filename = "${path.cwd}/auto_management_configuration.json"
58+
}
59+
60+
output "opt_in_status" {
61+
value = jsondecode(data.local_file.auto_management_configuration.content).OptInStatus
62+
}
63+
64+
output "opt_in_type" {
65+
value = jsondecode(data.local_file.auto_management_configuration.content).OptInType
66+
}
67+
68+
output "opt_in_level" {
69+
value = jsondecode(data.local_file.auto_management_configuration.content).OptInLevel
70+
}
71+
72+
output "notification_arn" {
73+
value = jsondecode(data.local_file.auto_management_configuration.content).NotificationArn
74+
}
75+
76+
output "exclusion_list" {
77+
value = jsondecode(data.local_file.auto_management_configuration.content).ExclusionList
78+
}
79+
80+
output "resource_aka" {
81+
value = "arn:${data.aws_partition.current.partition}:servicequotas:${data.aws_region.primary.name}:${data.aws_caller_identity.current.account_id}:auto-management-configuration"
82+
}

aws/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
696696
"aws_servicecatalog_portfolio_share": tableAwsServicecatalogPortfolioShare(ctx),
697697
"aws_servicecatalog_product": tableAwsServicecatalogProduct(ctx),
698698
"aws_servicecatalog_provisioned_product": tableAwsServicecatalogProvisionedProduct(ctx),
699+
"aws_servicequotas_auto_management_configuration": tableAwsServiceQuotasAutoManagementConfiguration(ctx),
699700
"aws_servicequotas_default_service_quota": tableAwsServiceQuotasDefaultServiceQuota(ctx),
700701
"aws_servicequotas_service_quota_change_request": tableAwsServiceQuotasServiceQuotaChangeRequest(ctx),
701702
"aws_servicequotas_service_quota": tableAwsServiceQuotasServiceQuota(ctx),
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
package aws
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/aws/aws-sdk-go-v2/service/servicequotas"
8+
9+
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
10+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
11+
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
12+
)
13+
14+
//// TABLE DEFINITION
15+
16+
func tableAwsServiceQuotasAutoManagementConfiguration(_ context.Context) *plugin.Table {
17+
return &plugin.Table{
18+
Name: "aws_servicequotas_auto_management_configuration",
19+
Description: "AWS Service Quotas Auto Management Configuration",
20+
DefaultIgnoreConfig: &plugin.IgnoreConfig{
21+
ShouldIgnoreErrorFunc: shouldIgnoreErrors([]string{"NoSuchResourceException"}),
22+
},
23+
List: &plugin.ListConfig{
24+
Hydrate: getAutoManagementConfiguration,
25+
Tags: map[string]string{"service": "servicequotas", "action": "GetAutoManagementConfiguration"},
26+
},
27+
GetMatrixItemFunc: SupportedRegionMatrix(AWS_SERVICEQUOTAS_SERVICE_ID),
28+
Columns: awsRegionalColumns([]*plugin.Column{
29+
{
30+
Name: "opt_in_status",
31+
Description: "Status on whether Automatic Management is started or stopped.",
32+
Type: proto.ColumnType_STRING,
33+
},
34+
{
35+
Name: "opt_in_type",
36+
Description: "Information on the opt-in type for Automatic Management. There are two modes: `NotifyOnly` (notify only) and `NotifyAndAdjust` (notify and auto-adjust).",
37+
Type: proto.ColumnType_STRING,
38+
},
39+
{
40+
Name: "opt_in_level",
41+
Description: "Information on the opt-in level for Automatic Management. Only ACCOUNT level is supported.",
42+
Type: proto.ColumnType_STRING,
43+
},
44+
{
45+
Name: "notification_arn",
46+
Description: "The User Notifications Amazon Resource Name (ARN) for Automatic Management notifications.",
47+
Type: proto.ColumnType_STRING,
48+
},
49+
{
50+
Name: "exclusion_list",
51+
Description: "List of Amazon Web Services services excluded from Automatic Management.",
52+
Type: proto.ColumnType_JSON,
53+
},
54+
55+
// Steampipe standard columns
56+
{
57+
Name: "title",
58+
Description: resourceInterfaceDescription("title"),
59+
Type: proto.ColumnType_STRING,
60+
Transform: transform.FromConstant("Auto Management Configuration"),
61+
},
62+
{
63+
Name: "akas",
64+
Description: resourceInterfaceDescription("akas"),
65+
Type: proto.ColumnType_JSON,
66+
Hydrate: getAutoManagementConfigurationAkas,
67+
Transform: transform.FromValue(),
68+
},
69+
}),
70+
}
71+
}
72+
73+
//// LIST FUNCTION
74+
75+
func getAutoManagementConfiguration(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
76+
// Create Session
77+
svc, err := ServiceQuotasClient(ctx, d)
78+
if err != nil {
79+
plugin.Logger(ctx).Error("aws_servicequotas_auto_management_configuration.getAutoManagementConfiguration", "connection_error", err)
80+
return nil, err
81+
}
82+
if svc == nil {
83+
// Unsupported region, return no data
84+
return nil, nil
85+
}
86+
87+
result, err := svc.GetAutoManagementConfiguration(ctx, &servicequotas.GetAutoManagementConfigurationInput{})
88+
if err != nil {
89+
plugin.Logger(ctx).Error("aws_servicequotas_auto_management_configuration.getAutoManagementConfiguration", "api_error", err)
90+
return nil, err
91+
}
92+
93+
d.StreamListItem(ctx, result)
94+
return nil, nil
95+
}
96+
97+
//// HYDRATE FUNCTIONS
98+
99+
func getAutoManagementConfigurationAkas(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
100+
region := d.EqualsQualString(matrixKeyRegion)
101+
102+
c, err := getCommonColumns(ctx, d, h)
103+
if err != nil {
104+
plugin.Logger(ctx).Error("aws_servicequotas_auto_management_configuration.getAutoManagementConfigurationAkas", "common_data_error", err)
105+
return nil, err
106+
}
107+
commonColumnData := c.(*awsCommonColumnData)
108+
arn := fmt.Sprintf("arn:%s:servicequotas:%s:%s:auto-management-configuration", commonColumnData.Partition, region, commonColumnData.AccountId)
109+
110+
return []string{arn}, nil
111+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: "Steampipe Table: aws_servicequotas_auto_management_configuration - Query AWS Service Quotas Auto Management Configuration using SQL"
3+
description: "Allows users to query AWS Service Quotas Automatic Management configuration, providing details on opt-in status, notification settings, and exclusion lists."
4+
folder: "Service Quotas"
5+
---
6+
7+
# Table: aws_servicequotas_auto_management_configuration - Query AWS Service Quotas Auto Management Configuration using SQL
8+
9+
AWS Service Quotas Automatic Management monitors your quota utilization and can automatically request increases when quotas approach their limits. This table returns the account-level configuration for Automatic Management per region.
10+
11+
## Table Usage Guide
12+
13+
The `aws_servicequotas_auto_management_configuration` table in Steampipe provides you with the Automatic Management configuration for each AWS region. This is a singleton table that returns one row per region, reflecting the current opt-in status, notification ARN, and any excluded services.
14+
15+
## Examples
16+
17+
### Check auto-management status across all regions
18+
Determine the Automatic Management opt-in status for each region.
19+
20+
```sql+postgres
21+
select
22+
region,
23+
opt_in_status,
24+
opt_in_type,
25+
opt_in_level
26+
from
27+
aws_servicequotas_auto_management_configuration;
28+
```
29+
30+
```sql+sqlite
31+
select
32+
region,
33+
opt_in_status,
34+
opt_in_type,
35+
opt_in_level
36+
from
37+
aws_servicequotas_auto_management_configuration;
38+
```
39+
40+
### Find regions with auto-management enabled
41+
Identify regions where Automatic Management is active.
42+
43+
```sql+postgres
44+
select
45+
region,
46+
opt_in_type,
47+
notification_arn
48+
from
49+
aws_servicequotas_auto_management_configuration
50+
where
51+
opt_in_status = 'ENABLED';
52+
```
53+
54+
```sql+sqlite
55+
select
56+
region,
57+
opt_in_type,
58+
notification_arn
59+
from
60+
aws_servicequotas_auto_management_configuration
61+
where
62+
opt_in_status = 'ENABLED';
63+
```
64+
65+
### View exclusion list details
66+
Explore which services are excluded from Automatic Management.
67+
68+
```sql+postgres
69+
select
70+
region,
71+
opt_in_status,
72+
exclusion_list
73+
from
74+
aws_servicequotas_auto_management_configuration
75+
where
76+
exclusion_list is not null;
77+
```
78+
79+
```sql+sqlite
80+
select
81+
region,
82+
opt_in_status,
83+
exclusion_list
84+
from
85+
aws_servicequotas_auto_management_configuration
86+
where
87+
exclusion_list is not null;
88+
```

0 commit comments

Comments
 (0)