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

Gets an empty Access Policy for Cloud Search Domain #5094

Closed
doron276 opened this issue Dec 4, 2023 · 4 comments
Closed

Gets an empty Access Policy for Cloud Search Domain #5094

doron276 opened this issue Dec 4, 2023 · 4 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@doron276
Copy link

doron276 commented Dec 4, 2023

Describe the bug

Hi,
I have two problems:

  1. I'm trying to fetch an Access Policy of Cloud Search Domain using AWS-SDK-for-Go.

See below code:

accessPolicy, err := client.DescribeServiceAccessPoliciesWithContext(ctx, &cloudsearch.DescribeServiceAccessPoliciesInput{DomainName: domainName})

I get a response without errors but the access policy is empty. For example (see empty value of "Options"):

{
    "AccessPolicies": {
        "Options": "",
        "Status": {
            "CreationDate": "2023-11-30T13:08:23.785000+00:00",
            "UpdateDate": "2023-11-30T13:21:29.655000+00:00",
            "UpdateVersion": 14,
            "State": "Active",
            "PendingDeletion": false
        }
    }
}

When I tried to use the same command in the AWS CLI, I got a response with a correct access policy. For Example:

{
    "AccessPolicies": {
        "Options": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"cloudsearch:*\"}]}",
        "Status": {
            "CreationDate": "2023-11-30T13:08:23.785000+00:00",
            "UpdateDate": "2023-11-30T13:21:29.655000+00:00",
            "UpdateVersion": 14,
            "State": "Active",
            "PendingDeletion": false
        }
    }
}
  1. Is it possible to get the Cloud Search domain tags? Please let me know if there is any way.

Please advise!
Thanks

Expected Behavior

Receive a response that contains the Cloud Search domain's access policy (like the response of CLI).

Current Behavior

I get a response without errors but the access policy is empty. For example (see empty value of "Options"):

{
    "AccessPolicies": {
        "Options": "",
        "Status": {
            "CreationDate": "2023-11-30T13:08:23.785000+00:00",
            "UpdateDate": "2023-11-30T13:21:29.655000+00:00",
            "UpdateVersion": 14,
            "State": "Active",
            "PendingDeletion": false
        }
    }
}

Reproduction Steps

Please use the "cloudsearchiface" function: "DescribeServiceAccessPoliciesWithContext" and see if you got a valid response with the access policy domain.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

v1.47.9

Environment details (Version of Go (go version)? OS name and version, etc.)

go version go1.21.3

@doron276 doron276 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 4, 2023
@RanVaknin RanVaknin self-assigned this Dec 4, 2023
@RanVaknin
Copy link
Contributor

Hi @doron276 ,

Is it possible to get the Cloud Search domain tags? Please let me know if there is any way.

I answered this on the second issue you opened here.

I get a response without errors but the access policy is empty. For example (see empty value of "Options"):

{
    "AccessPolicies": {
        "Options": "",
        "Status": {
            "CreationDate": "2023-11-30T13:08:23.785000+00:00",
            "UpdateDate": "2023-11-30T13:21:29.655000+00:00",
            "UpdateVersion": 14,
            "State": "Active",
            "PendingDeletion": false
        }
    }
}

It's not clear to me how you are seeing this JSON structure using the Go SDK, as the service responds in XML, not JSON:

  <DescribeServiceAccessPoliciesResult>
    <AccessPolicies>
      <Options>{&quot;Version&quot;:&quot;2012-10-17&quot;,&quot;Statement&quot;:[{&quot;Effect&quot;:&quot;Allow&quot;,&quot;Principal&quot;:{&quot;AWS&quot;:&quot;*&quot;},&quot;Action&quot;:&quot;cloudsearch:*&quot;}]}</Options>
      <Status>
        <UpdateDate>2023-12-04T23:29:00.601Z</UpdateDate>
        <UpdateVersion>5</UpdateVersion>
        <State>Processing</State>
        <CreationDate>2023-12-04T23:29:00.601Z</CreationDate>
        <PendingDeletion>false</PendingDeletion>
      </Status>
    </AccessPolicies>
  </DescribeServiceAccessPoliciesResult>
  <ResponseMetadata>
    <RequestId>56240b10-731d-47a7-9887-REDACTED</RequestId>
  </ResponseMetadata>
</DescribeServiceAccessPoliciesResponse>

So my code:

package main

import (
	"context"
	"fmt"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/cloudsearch"
)

func main() {
	sess, err := session.NewSession(&aws.Config{
		Region:   aws.String("us-east-1"),
		LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody),
	})
	if err != nil {
		panic(err)
	}

	client := cloudsearch.New(sess)

	out, err := client.DescribeServiceAccessPoliciesWithContext(context.Background(), &cloudsearch.DescribeServiceAccessPoliciesInput{
		DomainName: aws.String("foo-domain"),
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(*out.AccessPolicies.Options)

}

results in a correct policy being printed from Options:

{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"*"},"Action":"cloudsearch:*"}]}

Thanks,
Ran~

@RanVaknin RanVaknin added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Dec 4, 2023
Copy link

github-actions bot commented Dec 7, 2023

This issue has not received a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Dec 7, 2023
@doron276
Copy link
Author

Thanks for the answer @RanVaknin - My mistake.
Thanks for the quick help!

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Dec 11, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants