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

resource/aws_db_option_group: Add version field #2590

Merged
merged 1 commit into from
Apr 12, 2018
Merged

resource/aws_db_option_group: Add version field #2590

merged 1 commit into from
Apr 12, 2018

Conversation

chrisminton
Copy link
Contributor

@chrisminton chrisminton commented Dec 8, 2017

Fixes #748

Certain Oracle RDS options require a version attribute set, e.g. OEM_AGENT. This change adds that attribute to the option.

The acceptance test is wrong since I'm not sure about how to get the correct option number (obviously not option.0.version) from state. If anyone can give me a steer it would be appreciated.

@radeksimko radeksimko added the bug Addresses a defect in current functionality. label Dec 12, 2017
Copy link
Contributor

@Ninir Ninir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @chrisminton

This is looking good!

Just left a few comments to address / discuss before approving & merging.

"version": {
Type: schema.TypeString,
Optional: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this attribute be retrieved by the AWS API without a user setting it?
If so, this should also have a Computed: true, option

resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.#", "1"),
resource.TestCheckResourceAttr(
"aws_db_option_group.bar", "option.0.version", "12.1.0.4.v1"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As option is of type TypeSet (https://github.com/terraform-providers/terraform-provider-aws/pull/2590/files#diff-e61872fad819968684cae97c19506df5R70), a given entry can be retrieved with a hash, as in: https://github.com/chrisminton/terraform-provider-aws/blob/89c8a140afce2bc728b7e3e07c526f961c02f875/aws/resource_aws_db_option_group_test.go#L226

What I usually do is get the hash from the logs, using TF_LOG=DEBUG with TF_LOG_PATH=terraform.log as in:

TF_LOG=DEBUG make testacc TEST=./aws TESTARGS='-run= TestAccAWSDBOptionGroup_multipleOptions'

This will put multiple log lines in the aws/terraform.log file, making it easier for you to debug :)

Note that the hash will change if parts of the option change.

@radeksimko radeksimko added the service/rds Issues and PRs that pertain to the rds service. label Jan 16, 2018
@radeksimko radeksimko changed the title Update RDS Option groups to allow version option resource/aws_db_option_group: Add version field Jan 16, 2018
@Ninir
Copy link
Contributor

Ninir commented Jan 30, 2018

Hi @chrisminton

Do you think you would have time to fix the comments so that we get this merged?

Thanks!

@Ninir Ninir added the waiting-response Maintainers are waiting on response from community or contributor. label Jan 30, 2018
@chrisminton
Copy link
Contributor Author

chrisminton commented Jan 30, 2018

Hi @Ninir - yes! I've been caught up in other matters. It looks to me that the hash changes every time in the debug logs so this may not be a useful test but i'll test again. The version attribute does not require Computed: true, it must be user-set.

@nmische
Copy link

nmische commented Apr 12, 2018

Is there any update on this issue? This is blocking us from being able to manage Oracle RDS with Terraform. Thanks.

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Apr 12, 2018
@bflad bflad added this to the v1.15.0 milestone Apr 12, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work here @chrisminton! I have a commit following yours which fixes the testing. Since we don't know the hash value, we can check the returned *rds.OptionGroup directly:

func testAccCheckAWSDBOptionGroupOptionVersionAttribute(optionGroup *rds.OptionGroup, optionVersion string) resource.TestCheckFunc {
	return func(s *terraform.State) error {
		if optionGroup == nil {
			return errors.New("Option Group does not exist")
		}
		if len(optionGroup.Options) == 0 {
			return errors.New("Option Group does not have any options")
		}
		foundOptionVersion := aws.StringValue(optionGroup.Options[0].OptionVersion)
		if foundOptionVersion != optionVersion {
			return fmt.Errorf("Expected option version %q and received %q", optionVersion, foundOptionVersion)
		}
		return nil
	}
}

It also needed to only optionally be added to the TypeSet hash (otherwise would show as a difference when anyone upgraded):

if v, ok := m["version"]; ok && v.(string) != "" {
	buf.WriteString(fmt.Sprintf("%s-", v.(string)))
}

With that, we're all set!

make testacc TEST=./aws TESTARGS='-run=TestAccAWSDBOptionGroup'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSDBOptionGroup -timeout 120m
=== RUN   TestAccAWSDBOptionGroup_importBasic
--- PASS: TestAccAWSDBOptionGroup_importBasic (14.62s)
=== RUN   TestAccAWSDBOptionGroup_basic
--- PASS: TestAccAWSDBOptionGroup_basic (12.23s)
=== RUN   TestAccAWSDBOptionGroup_timeoutBlock
--- PASS: TestAccAWSDBOptionGroup_timeoutBlock (14.70s)
=== RUN   TestAccAWSDBOptionGroup_namePrefix
--- PASS: TestAccAWSDBOptionGroup_namePrefix (13.23s)
=== RUN   TestAccAWSDBOptionGroup_generatedName
--- PASS: TestAccAWSDBOptionGroup_generatedName (12.33s)
=== RUN   TestAccAWSDBOptionGroup_defaultDescription
--- PASS: TestAccAWSDBOptionGroup_defaultDescription (12.45s)
=== RUN   TestAccAWSDBOptionGroup_basicDestroyWithInstance
--- PASS: TestAccAWSDBOptionGroup_basicDestroyWithInstance (482.69s)
=== RUN   TestAccAWSDBOptionGroup_OptionSettings
--- PASS: TestAccAWSDBOptionGroup_OptionSettings (11.07s)
=== RUN   TestAccAWSDBOptionGroup_sqlServerOptionsUpdate
--- PASS: TestAccAWSDBOptionGroup_sqlServerOptionsUpdate (23.07s)
=== RUN   TestAccAWSDBOptionGroup_OracleOptionsUpdate
--- PASS: TestAccAWSDBOptionGroup_OracleOptionsUpdate (31.28s)
=== RUN   TestAccAWSDBOptionGroup_multipleOptions
--- PASS: TestAccAWSDBOptionGroup_multipleOptions (13.87s)

@bflad bflad merged commit 89c8a14 into hashicorp:master Apr 12, 2018
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. and removed bug Addresses a defect in current functionality. labels Apr 12, 2018
bflad added a commit that referenced this pull request Apr 12, 2018
@chrisminton
Copy link
Contributor Author

Thanks @bflad and sorry I didn't have any time to get back to this!

@nmische
Copy link

nmische commented Apr 13, 2018

Thanks for getting this merged!

@bflad
Copy link
Contributor

bflad commented Apr 18, 2018

This has been released in version 1.15.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@chrisminton chrisminton deleted the add-version-option-group branch April 18, 2018 22:01
@ghost
Copy link

ghost commented Apr 6, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_db_option_group - OEM_AGENT
5 participants