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

add data source for retrieving the root Organizational Unit #4229

Merged
merged 3 commits into from
May 8, 2019

Conversation

afeld
Copy link
Contributor

@afeld afeld commented Apr 17, 2018

Part of #571.

Corresponds to this API. The motivation here is that I want to be able to create Organizational Units (OUs) from Terraform (see #4207), but to do so I need the ID of the root OU.

Acceptance tests pass:

$ make testacc TEST=./aws TESTARGS="-run OrganizationRoot"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run OrganizationRoot -timeout 120m
=== RUN   TestAccDataSourceAwsOrganizationRoot_basic
--- PASS: TestAccDataSourceAwsOrganizationRoot_basic (10.44s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	31.309s

Also tried with with an actual test case:

data "aws_organizations_root" "root" {}

output "arn" {
  value = "${data.aws_organizations_root.root.arn}"
}

output "id" {
  value = "${data.aws_organizations_root.root.id}"
}
$ $GOPATH/bin/terraform apply
data.aws_organizations_root.root: Refreshing state...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

arn = arn:aws:organizations::422624340815:root/o-pwk4n5w06h/r-bgtv
id = r-bgtv

Thanks!

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 17, 2018
"github.com/hashicorp/terraform/terraform"
)

func TestAccDataSourceAwsOrganizationRoot_basic(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to worry about Organizations possibly not being enabled?

@afeld afeld mentioned this pull request Apr 17, 2018
4 tasks
@bflad bflad added new-data-source Introduces a new data source. service/organizations Issues and PRs that pertain to the organizations service. labels Apr 17, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 18, 2018
@afeld
Copy link
Contributor Author

afeld commented Apr 18, 2018

Decided that having a single data source for organizational units (in the future) made more sense than having a special one for roots, so changed the naming around.

aws/provider.go Outdated
@@ -221,6 +221,7 @@ func Provider() terraform.ResourceProvider {
"aws_region": dataSourceAwsRegion(),
"aws_route_table": dataSourceAwsRouteTable(),
"aws_route53_zone": dataSourceAwsRoute53Zone(),
"aws_organizations_unit": dataSourceAwsOrganizationUnit(),
Copy link

Choose a reason for hiding this comment

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

The data sources in this code are in alphabetical order but this is between r and s when it should be n and p.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

D'oh, fixed!

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label May 1, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label May 1, 2018
@afeld
Copy link
Contributor Author

afeld commented May 4, 2018

Anything else needed here?

@ghost ghost added provider Pertains to the provider itself, rather than any interaction with AWS. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. documentation Introduces or discusses updates to documentation. labels Dec 27, 2018
@ndobbs
Copy link

ndobbs commented Jan 25, 2019

Is this data source ready to be reviewed // accepted? @breser

@bflad bflad merged commit 20959bf into hashicorp:master May 8, 2019
@bflad
Copy link
Contributor

bflad commented May 8, 2019

FYI: The commits from this pull request were included with #4207 to add the aws_organizations_organizational_unit resource, but later removed in that pull request which was just merged, which is why this is showing as merged. There is currently no aws_organizations_organizational_unit data source in the Terraform AWS Provider as of right now. Please track the originating issue #571 for further information, thanks!

@breser
Copy link

breser commented May 8, 2019

@ndobbs Not sure why you're asking me and I'd missed that you had till now. But yes I think that data source could be merged. I was using at a previous job with a custom built copy of the aws provider. But I'm not longer with the company that we were using it.

@ghost
Copy link

ghost commented Mar 30, 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 Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. new-data-source Introduces a new data source. provider Pertains to the provider itself, rather than any interaction with AWS. service/organizations Issues and PRs that pertain to the organizations service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants