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

docs: Add examples and AWS documentation to aws_opensearchserverless_access… #32571

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 99 additions & 16 deletions website/docs/r/opensearchserverless_access_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,121 @@ description: |-

# Resource: aws_opensearchserverless_access_policy

Terraform resource for managing an AWS OpenSearch Serverless Access Policy.
Terraform resource for managing an AWS OpenSearch Serverless Access Policy. See AWS documentation for [data access policies](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-data-access.html) and [supported data access policy permissions](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-data-access.html#serverless-data-supported-permissions).

## Example Usage

### Basic Usage
### Grant all collection and index permissions

```terraform
data "aws_caller_identity" "current" {}
data "aws_partition" "current" {}

resource "aws_opensearchserverless_access_policy" "test" {
resource "aws_opensearchserverless_access_policy" "example" {
name = "example"
type = "data"
description = "read and write permissions"
policy = jsonencode([
{
Rules = [
{
ResourceType = "index",
Resource = [
"index/example-collection/*"
],
Permission = [
"aoss:*"
]
},
{
ResourceType = "collection",
Resource = [
"collection/example-collection"
],
Permission = [
"aoss:*"
]
}
],
Principal = [
data.aws_caller_identity.current.arn
]
}
])
}
```

### Grant read-only collection and index permissions

```
data "aws_caller_identity" "current" {}

resource "aws_opensearchserverless_access_policy" "example" {
name = "example"
type = "data"
description = "read-only permissions"
policy = jsonencode([
{
Rules = [
{
ResourceType = "index",
Resource = [
"index/example-collection/*"
],
Permission = [
"aoss:DescribeIndex",
"aoss:ReadDocument",
]
},
{
ResourceType = "collection",
Resource = [
"collection/example-collection"
],
Permission = [
"aoss:DescribeCollectionItems"
]
}
],
Principal = [
data.aws_caller_identity.current.arn
]
}
])
}
```

### Grant SAML identity permissions

```
resource "aws_opensearchserverless_access_policy" "example" {
name = "example"
type = "data"
description = "saml permissions"
policy = jsonencode([
{
"Rules" : [
Rules = [
{
"ResourceType" : "index",
"Resource" : [
"index/books/*"
ResourceType = "index",
Resource = [
"index/example-collection/*"
],
"Permission" : [
"aoss:CreateIndex",
"aoss:ReadDocument",
"aoss:UpdateIndex",
"aoss:DeleteIndex",
"aoss:WriteDocument"
Permission = [
"aoss:*"
]
},
{
ResourceType = "collection",
Resource = [
"collection/example-collection"
],
Permission = [
"aoss:*"
]
}
],
"Principal" : [
"arn:${data.aws_partition.current.partition}:iam::${data.aws_caller_identity.current.account_id}:user/admin"
Principal = [
"saml/123456789012/myprovider/user/Annie",
"saml/123456789012/anotherprovider/group/Accounting"
]
}
])
Expand Down
Loading