Skip to content

Commit

Permalink
Documentation for the AWS DB Option resource
Browse files Browse the repository at this point in the history
  • Loading branch information
stack72 committed Jan 18, 2016
1 parent f6a2ea2 commit 790a568
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 24 deletions.
4 changes: 4 additions & 0 deletions builtin/providers/aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
opts.Port = aws.Int64(int64(attr.(int)))
}

if attr, ok := d.GetOk("storage_type"); ok {
opts.StorageType = aws.String(attr.(string))
}

if attr, ok := d.GetOk("publicly_accessible"); ok {
opts.PubliclyAccessible = aws.Bool(attr.(bool))
}
Expand Down
30 changes: 15 additions & 15 deletions builtin/providers/aws/resource_aws_db_option_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func resourceAwsDbOptionGroup() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"option_group_name": &schema.Schema{
"name": &schema.Schema{
Type: schema.TypeString,
ForceNew: true,
Required: true,
Expand Down Expand Up @@ -81,12 +81,6 @@ func resourceAwsDbOptionGroup() *schema.Resource {
Set: resourceAwsDbOptionHash,
},

"apply_immediately": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
},

"tags": tagsSchema(),
},
}
Expand All @@ -100,7 +94,7 @@ func resourceAwsDbOptionGroupCreate(d *schema.ResourceData, meta interface{}) er
EngineName: aws.String(d.Get("engine_name").(string)),
MajorEngineVersion: aws.String(d.Get("major_engine_version").(string)),
OptionGroupDescription: aws.String(d.Get("option_group_description").(string)),
OptionGroupName: aws.String(d.Get("option_group_name").(string)),
OptionGroupName: aws.String(d.Get("name").(string)),
Tags: tags,
}

Expand All @@ -110,16 +104,16 @@ func resourceAwsDbOptionGroupCreate(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error creating DB Option Group: %s", err)
}

d.SetId(d.Get("option_group_name").(string))
d.SetId(d.Get("name").(string))
log.Printf("[INFO] DB Option Group ID: %s", d.Id())

return resourceAwsDbOptionGroupRead(d, meta)
return resourceAwsDbOptionGroupUpdate(d, meta)
}

func resourceAwsDbOptionGroupRead(d *schema.ResourceData, meta interface{}) error {
rdsconn := meta.(*AWSClient).rdsconn
params := &rds.DescribeOptionGroupsInput{
OptionGroupName: aws.String(d.Get("option_group_name").(string)),
OptionGroupName: aws.String(d.Get("name").(string)),
}

log.Printf("[DEBUG] Describe DB Option Group: %#v", params)
Expand All @@ -128,8 +122,15 @@ func resourceAwsDbOptionGroupRead(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error Describing DB Option Group: %s", err)
}

if len(options.OptionGroupsList) != 1 ||
*options.OptionGroupsList[0].OptionGroupName != d.Id() {
var option *rds.OptionGroup
for _, ogl := range options.OptionGroupsList {
if *ogl.OptionGroupName == d.Get("name").(string) {
option = ogl
break
}
}

if option == nil {
return fmt.Errorf("Unable to find Option Group: %#v", options.OptionGroupsList)
}

Expand Down Expand Up @@ -189,8 +190,7 @@ func resourceAwsDbOptionGroupUpdate(d *schema.ResourceData, meta interface{}) er
}

modifyOpts := &rds.ModifyOptionGroupInput{
OptionGroupName: aws.String(d.Id()),
ApplyImmediately: aws.Bool(d.Get("apply_immediately").(bool)),
OptionGroupName: aws.String(d.Id()),
}

if len(addOptions) > 0 {
Expand Down
18 changes: 9 additions & 9 deletions builtin/providers/aws/resource_aws_db_option_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccAWSDBOptionGroup_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option_group_name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
),
},
},
Expand All @@ -44,7 +44,7 @@ func TestAccAWSDBOptionGroup_sqlServerOptions(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option_group_name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "2"),
),
Expand All @@ -66,7 +66,7 @@ func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option_group_name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "2"),
),
Expand All @@ -77,7 +77,7 @@ func TestAccAWSDBOptionGroup_sqlServerOptionsUpdate(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option_group_name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "1"),
),
Expand All @@ -99,7 +99,7 @@ func TestAccAWSDBOptionGroup_mysqlPort(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBOptionGroupExists("aws_db_option_group.bar", &v),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option_group_name", "option-group-test-terraform"),
"aws_db_option_group.bar", "name", "option-group-test-terraform"),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "1"),
),
Expand Down Expand Up @@ -213,7 +213,7 @@ func testAccCheckAWSDBOptionGroupDestroy(s *terraform.State) error {

const testAccAWSDBOptionGroupBasicConfig = `
resource "aws_db_option_group" "bar" {
option_group_name = "option-group-test-terraform"
name = "option-group-test-terraform"
option_group_description = "Test option group for terraform"
engine_name = "mysql"
major_engine_version = "5.6"
Expand All @@ -222,7 +222,7 @@ resource "aws_db_option_group" "bar" {

const testAccAWSDBOptionGroupSqlServerEEOptions = `
resource "aws_db_option_group" "bar" {
option_group_name = "option-group-test-terraform"
name = "option-group-test-terraform"
option_group_description = "Test option group for terraform"
engine_name = "sqlserver-ee"
major_engine_version = "11.00"
Expand All @@ -239,7 +239,7 @@ resource "aws_db_option_group" "bar" {

const testAccAWSDBOptionGroupSqlServerEEOptions_update = `
resource "aws_db_option_group" "bar" {
option_group_name = "option-group-test-terraform"
name = "option-group-test-terraform"
option_group_description = "Test option group for terraform"
engine_name = "sqlserver-ee"
major_engine_version = "11.00"
Expand All @@ -252,7 +252,7 @@ resource "aws_db_option_group" "bar" {

const testAccAWSDBOptionGroupMySQLOptions = `
resource "aws_db_option_group" "bar" {
option_group_name = "option-group-test-terraform"
name = "option-group-test-terraform"
option_group_description = "Test option group for terraform"
engine_name = "mysql"
major_engine_version = "5.6"
Expand Down
54 changes: 54 additions & 0 deletions website/source/docs/providers/aws/r/db_option_group.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
layout: "aws"
page_title: "AWS: aws_db_option_group"
sidebar_current: "docs-aws-resource-db-option-group"
---

# aws\_db\_option\_group

Provides an RDS DB option group resource.

## Example Usage

```
resource "aws_db_option_group" "bar" {
option_group_name = "option-group-test-terraform"
option_group_description = "Terraform Option Group"
engine_name = "sqlserver-ee"
major_engine_version = "11.00"
option {
option_name = "mirroring"
}
option {
option_name = "TDE"
}
apply_immediately = true
}
```

## Argument Reference

The following arguments are supported:

* `option_group_name` - (Required) The name of the Option group to be created.
* `option_group_description` - (Required) The description of the option group.
* `engine_name` - (Required) Specifies the name of the engine that this option group should be associated with..
* `major_engine_version` - (Required) Specifies the major version of the engine that this option group should be associated with.
* `parameter` - (Optional) A list of Options to apply.
* `tags` - (Optional) A mapping of tags to assign to the resource.

Parameter blocks support the following:

* `option_name` - (Required) The Name of the Option (e.g. MEMCACHED).
* `port` - (Optional) The Port number when connecting to the Option (e.g. 11211).
* `db_security_group_memberships` - (Optional) A list of DB Security Groups for which the option is enabled.
* `vpc_security_group_memberships` - (Optional) A list of VPC Security Groups for which the option is enabled.

## Attributes Reference

The following attributes are exported:

* `arn` - The ARN of the db option group.
4 changes: 4 additions & 0 deletions website/source/layouts/aws.erb
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@
<a href="/docs/providers/aws/r/db_instance.html">aws_db_instance</a>
</li>

<li<%= sidebar_current("docs-aws-resource-db-option-group") %>>
<a href="/docs/providers/aws/r/db_option_group.html">aws_db_poption_group</a>
</li>

<li<%= sidebar_current("docs-aws-resource-db-parameter-group") %>>
<a href="/docs/providers/aws/r/db_parameter_group.html">aws_db_parameter_group</a>
</li>
Expand Down

0 comments on commit 790a568

Please sign in to comment.