Skip to content

Commit

Permalink
resource/aws_servicequotas_service_quota: Add adjustable, arn, defaul…
Browse files Browse the repository at this point in the history
…t_value, quota_name, and service_name attributes

Output from acceptance testing:

```
--- PASS: TestAccAwsServiceQuotasServiceQuota_basic (12.28s)
```
  • Loading branch information
bflad committed Jun 28, 2019
1 parent 1823372 commit 6ccd9e9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
40 changes: 40 additions & 0 deletions aws/resource_aws_servicequotas_service_quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,27 @@ func resourceAwsServiceQuotasServiceQuota() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"adjustable": {
Type: schema.TypeBool,
Computed: true,
},
"arn": {
Type: schema.TypeString,
Computed: true,
},
"default_value": {
Type: schema.TypeFloat,
Computed: true,
},
"quota_code": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"quota_name": {
Type: schema.TypeString,
Computed: true,
},
"request_id": {
Type: schema.TypeString,
Computed: true,
Expand All @@ -38,6 +54,10 @@ func resourceAwsServiceQuotasServiceQuota() *schema.Resource {
Required: true,
ForceNew: true,
},
"service_name": {
Type: schema.TypeString,
Computed: true,
},
"value": {
Type: schema.TypeFloat,
Required: true,
Expand Down Expand Up @@ -118,8 +138,28 @@ func resourceAwsServiceQuotasServiceQuotaRead(d *schema.ResourceData, meta inter
return fmt.Errorf("error getting Service Quotas Service Quota (%s): empty result", d.Id())
}

defaultInput := &servicequotas.GetAWSDefaultServiceQuotaInput{
QuotaCode: aws.String(quotaCode),
ServiceCode: aws.String(serviceCode),
}

defaultOutput, err := conn.GetAWSDefaultServiceQuota(defaultInput)

if err != nil {
return fmt.Errorf("error getting Service Quotas Default Service Quota (%s): %s", d.Id(), err)
}

if output == nil {
return fmt.Errorf("error getting Service Quotas Default Service Quota (%s): empty result", d.Id())
}

d.Set("adjustable", output.Quota.Adjustable)
d.Set("arn", output.Quota.QuotaArn)
d.Set("default_value", defaultOutput.Quota.Value)
d.Set("quota_code", output.Quota.QuotaCode)
d.Set("quota_name", output.Quota.QuotaName)
d.Set("service_code", output.Quota.ServiceCode)
d.Set("service_name", output.Quota.ServiceName)
d.Set("value", output.Quota.Value)

if requestID != "" {
Expand Down
5 changes: 5 additions & 0 deletions aws/resource_aws_servicequotas_service_quota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ func TestAccAwsServiceQuotasServiceQuota_basic(t *testing.T) {
{
Config: testAccAwsServiceQuotasServiceQuotaConfig(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "adjustable", "true"),
testAccCheckResourceAttrRegionalARN(resourceName, "arn", "servicequotas", "vpc/L-F678F1CE"),
resource.TestCheckResourceAttr(resourceName, "default_value", "5"),
resource.TestCheckResourceAttr(resourceName, "quota_code", "L-F678F1CE"),
resource.TestCheckResourceAttr(resourceName, "quota_name", "VPCs per Region"),
resource.TestCheckResourceAttr(resourceName, "service_code", "vpc"),
resource.TestCheckResourceAttr(resourceName, "service_name", "Amazon Virtual Private Cloud (Amazon VPC)"),
resource.TestCheckResourceAttr(resourceName, "value", "75"),
),
},
Expand Down
7 changes: 7 additions & 0 deletions website/docs/r/servicequotas_service_quota.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ The following arguments are supported:

## Attribute Reference

In addition to all arguments above, the following attributes are exported:

* `adjustable` - Whether the service quota can be increased.
* `arn` - Amazon Resource Name (ARN) of the service quota.
* `default_value` - Default value of the service quota.
* `id` - Service code and quota code, separated by a front slash (`/`)
* `quota_name` - Name of the quota.
* `service_name` - Name of the service.

## Import

Expand Down

0 comments on commit 6ccd9e9

Please sign in to comment.