AWS OpenSearch Serverless - returning 403 error with correct access policy

0

I’m trying to create a REST API on my lambda to create a document within my opensearch serverless collection.

I’m able to do this manually through the dashboard. However, while trying to hit the endpoint I’m getting 403 errors.

I have granted all access on my access policy and followed the tutorial and even this re:Post article (https://repost.aws/questions/QU32hRu7KtQd-XWauqWXMjqQ/opensearch-serverless-javascript-content-length-403-error) but still no luck.

Any help would be greatly appreciated.

1개 답변
4
수락된 답변

Assuming your data access policy is configured properly, make sure your Lambda function's execution role has aoss:APIAccessAll permissions applied for data-plane access, see Using data-plane policies

AWS
답변함 일 년 전
  • I have added those into my IAM but still getting a 403 error.

    Heres a snippet of my data access policy: policy = jsonencode([{ "Rules" : [ { "ResourceType" : "index", "Resource" : [ "index/my-data-collection-${var.stage}/*" ], "Permission" : [ "aoss:CreateIndex", "aoss:ReadDocument", "aoss:UpdateIndex", "aoss:WriteDocument", "aoss:*" ]}], "Principal" : [ "arn:${partition}:iam::${account_id}:user/${stage}"]

    And a snippet of my IAM: `iamRoleStatements:

    • Effect: Allow Action:
    • aoss:APIAccessAll Resource:
    • arn:aws:aoss:${aws:region}:${aws:accountId}:collection/id`
  • Is that the full data access policy? If so, you will need to add the ARN of the Lamaba function's execution role to the Principal element.

    For example

    policy = jsonencode([
    { 
        "Rules" : [{
            "ResourceType" : "index", 
            "Resource" : [ 
                "index/my-data-collection-${var.stage}/*" ], 
                "Permission" : [ 
                        "aoss:CreateIndex",
                        "aoss:ReadDocument",
                        "aoss:UpdateIndex",
                        "aoss:WriteDocument",
                        "aoss:*"
                  ]
          }], 
          "Principal" : [
                "arn:${partition}:iam::${account_id}:user/${stage}",
                "arn:${partition}:iam::${account_id}:role/${LambdaExecutionRoleName}"
           ]
    

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠