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

[#19966] - aws_elasticsearch_domain_saml_options subject_key default differs from AWS #20892

Conversation

jc-asdf
Copy link
Contributor

@jc-asdf jc-asdf commented Sep 14, 2021

Fixed by making the subject_key's default value be "" - an empty string - to match the default on the AWS side.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #19966

Output from acceptance testing:

 AWS_REGION=us-east-1 AWS_PROFILE=sandbox make testacc TESTARGS='-run=TestAccAWSElasticSearchDomainSAMLOptions'

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 20 -run=TestAccAWSElasticSearchDomainSAMLOptions -timeout 180m
=== RUN   TestAccAWSElasticSearchDomainSAMLOptions_basic
=== PAUSE TestAccAWSElasticSearchDomainSAMLOptions_basic
=== RUN   TestAccAWSElasticSearchDomainSAMLOptions_disappears
=== PAUSE TestAccAWSElasticSearchDomainSAMLOptions_disappears
=== RUN   TestAccAWSElasticSearchDomainSAMLOptions_disappears_Domain
=== PAUSE TestAccAWSElasticSearchDomainSAMLOptions_disappears_Domain
=== RUN   TestAccAWSElasticSearchDomainSAMLOptions_Update
=== PAUSE TestAccAWSElasticSearchDomainSAMLOptions_Update
=== RUN   TestAccAWSElasticSearchDomainSAMLOptions_Disabled
=== PAUSE TestAccAWSElasticSearchDomainSAMLOptions_Disabled
=== CONT  TestAccAWSElasticSearchDomainSAMLOptions_basic
=== CONT  TestAccAWSElasticSearchDomainSAMLOptions_Update
=== CONT  TestAccAWSElasticSearchDomainSAMLOptions_Disabled
=== CONT  TestAccAWSElasticSearchDomainSAMLOptions_disappears_Domain
=== CONT  TestAccAWSElasticSearchDomainSAMLOptions_disappears
--- PASS: TestAccAWSElasticSearchDomainSAMLOptions_disappears_Domain (1263.67s)
--- PASS: TestAccAWSElasticSearchDomainSAMLOptions_basic (1323.29s)
--- PASS: TestAccAWSElasticSearchDomainSAMLOptions_Update (1380.93s)
--- PASS: TestAccAWSElasticSearchDomainSAMLOptions_disappears (1580.45s)
--- PASS: TestAccAWSElasticSearchDomainSAMLOptions_Disabled (1713.77s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	1716.013s

@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/elasticsearch Issues and PRs that pertain to the elasticsearch service. labels Sep 14, 2021
@jc-asdf
Copy link
Contributor Author

jc-asdf commented Sep 14, 2021

To verify the AWS-side default, I created a working Elasticsearch cluster via the AWS UI, enabling SAML with our Okta integration, leaving the subject key field empty. I got it working from end-to-end - from signing into SSO (Okta), through to the Kibana interface.

I verified that the SAML assertion had a NameID element in the Subject section - it did. I used the CLI to do a describe:

aws es describe-elasticsearch-domain --domain-name=audit-app-staging --profile=sandbox --region=us-east-1

{
    "DomainStatus": {
        "DomainId": "XXXXXXXX/terraform-test-saml",
        "DomainName": "terraform-test-saml",
        "ARN": "arn:aws:es:us-east-1:XXXXXXXX:domain/terraform-test-saml",
        "Created": true,
        "Deleted": false,

... <cut out the bulk> ...

        "AdvancedSecurityOptions": {
            "Enabled": true,
            "InternalUserDatabaseEnabled": false,
            "SAMLOptions": {
                "Enabled": true,
                "Idp": {
                    ... <cut out the XML idP metadata> ...
                },
                "SubjectKey": "",
                "RolesKey": "roles",
                "SessionTimeoutMinutes": 60
            }
        },
        "AutoTuneOptions": {
            "State": "ENABLE_IN_PROGRESS"
        }
    }
}

From here I could see that SubjectKey was in fact an empty string. I replicated the original bug by setting the SubjectKey to NameID (which, incidentally, can NOT be done in the AWS UI - it says that this is an invalid option; and so one must use the API to set it to this value). Once it was changed, I received a 500 error from Kibana; unfortunately I could not get useful error logs from it. The errors went away once this was changed back to a "", whether in the UI or via the API.

@justinretzolk justinretzolk added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 14, 2021
@zhelding
Copy link
Contributor

Pull request #21306 has significantly refactored the AWS Provider codebase. As a result, most PRs opened prior to the refactor now have merge conflicts that must be resolved before proceeding.

Specifically, PR #21306 relocated the code for all AWS resources and data sources from a single aws directory to a large number of separate directories in internal/service, each corresponding to a particular AWS service. This separation of code has also allowed for us to simplify the names of underlying functions -- while still avoiding namespace collisions.

We recognize that many pull requests have been open for some time without yet being addressed by our maintainers. Therefore, we want to make it clear that resolving these conflicts in no way affects the prioritization of a particular pull request. Once a pull request has been prioritized for review, the necessary changes will be made by a maintainer -- either directly or in collaboration with the pull request author.

For a more complete description of this refactor, including examples of how old filepaths and function names correspond to their new counterparts: please refer to issue #20000.

For a quick guide on how to amend your pull request to resolve the merge conflicts resulting from this refactor and bring it in line with our new code patterns: please refer to our Service Package Refactor Pull Request Guide.

@jc-asdf
Copy link
Contributor Author

jc-asdf commented Oct 19, 2021

The changes in paths from #20000 have been merged in; this PR is compliant with the updated style / layout.

@Jacendb
Copy link

Jacendb commented Dec 2, 2021

I'm seeing the same issue when creating a new ES domain. Does subject_key need a default value? In the AWS console I currently have to remove NameID and leave the Subject key box empty for SSO/Okta to work. I'm wondering if not setting anything in default will leave the field untouched/undefined on the AWS side so it works.

@ewbankkit ewbankkit added the breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. label Mar 23, 2022
@YakDriver YakDriver self-assigned this Mar 25, 2022
@YakDriver
Copy link
Member

I agree that normally, changing the default value is a breaking change. However, in this case, the old and new default values are equivalent. Thus, I don't see this as a breaking change.

@YakDriver YakDriver force-pushed the b-aws_elasticsearch_domain_saml_options-fix-defaults branch from 4383790 to bf113c3 Compare March 25, 2022 22:11
@github-actions github-actions bot added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Mar 25, 2022
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

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

Thank you 🎉

% make testacc TESTS=TestAccElasticsearchDomainSAMLOptions PKG=elasticsearch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/elasticsearch/... -v -count 1 -parallel 20 -run='TestAccElasticsearchDomainSAMLOptions'  -timeout 180m
--- PASS: TestAccElasticsearchDomainSAMLOptions_disappears (1178.57s)
--- PASS: TestAccElasticsearchDomainSAMLOptions_Update (1202.84s)
--- PASS: TestAccElasticsearchDomainSAMLOptions_disappears_Domain (1268.98s)
--- PASS: TestAccElasticsearchDomainSAMLOptions_Disabled (1373.32s)
--- PASS: TestAccElasticsearchDomainSAMLOptions_basic (1450.98s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/elasticsearch	1452.310s

@github-actions
Copy link

github-actions bot commented Apr 7, 2022

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented May 8, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change Introduces a breaking change in current functionality; usually deferred to the next major release. bug Addresses a defect in current functionality. documentation Introduces or discusses updates to documentation. service/elasticsearch Issues and PRs that pertain to the elasticsearch service. size/XS 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.

aws_elasticsearch_domain_saml_options subject_key default differs from AWS
6 participants