generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1751 from quixoticmonk/d-improve-awscc_qbusiness_…
…data_source docs: added example for awscc_qbusiness_data_source
- Loading branch information
Showing
3 changed files
with
267 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
examples/resources/awscc_qbusiness_data_source/qbusiness_data_source.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
resource "awscc_qbusiness_data_source" "exaple" { | ||
application_id = awscc_qbusiness_application.example.application_id | ||
display_name = "example_q_data_source" | ||
index_id = awscc_qbusiness_index.example.index_id | ||
role_arn = awscc_iam_role.ds.arn | ||
configuration = jsonencode( | ||
{ | ||
type = "S3" | ||
version = "1.0.0" | ||
syncMode = "FORCED_FULL_CRAWL" | ||
connectionConfiguration = { | ||
repositoryEndpointMetadata = { | ||
BucketName = var.bucket_name | ||
} | ||
} | ||
additionalProperties = { | ||
inclusionPrefixes = ["docs/"] | ||
} | ||
repositoryConfigurations = { | ||
document = { | ||
fieldMappings = [ | ||
{ | ||
dataSourceFieldName = "s3_document_id" | ||
indexFieldType = "STRING" | ||
indexFieldName = "s3_document_id" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
) | ||
tags = [{ | ||
key = "Modified By" | ||
value = "AWSCC" | ||
}] | ||
} | ||
|
||
resource "awscc_iam_role" "example" { | ||
role_name = "QBusiness-DataSource-Role" | ||
description = "QBusiness Data source role" | ||
assume_role_policy_document = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Sid = "AllowsAmazonQToAssumeRoleForServicePrincipal" | ||
Effect = "Allow" | ||
Principal = { | ||
Service = "qbusiness.amazonaws.com" | ||
} | ||
Action = [ | ||
"sts:AssumeRole" | ||
] | ||
Condition = { | ||
StringEquals = { | ||
"aws:SourceAccount" = data.aws_caller_identity.current.account_id | ||
} | ||
} | ||
} | ||
] | ||
}) | ||
|
||
tags = [{ | ||
key = "Modified By" | ||
value = "AWSCC" | ||
}] | ||
} | ||
|
||
resource "awscc_iam_role_policy" "example" { | ||
policy_name = "sample_iam_role_policy" | ||
role_name = awscc_iam_role.ds.id | ||
|
||
policy_document = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow" | ||
Action = "s3:GetObject" | ||
Resource = "arn:aws:s3:::${var.bucket_name}/*" | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = "s3:ListBucket" | ||
Resource = "arn:aws:s3:::${var.bucket_name}" | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"qbusiness:BatchPutDocument", | ||
"qbusiness:BatchDeleteDocument" | ||
] | ||
Resource = "arn:aws:qbusiness:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:application/${awscc_qbusiness_application.example.id}/index/${awscc_qbusiness_index.example.id}" | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = ["qbusiness:PutGroup", | ||
"qbusiness:CreateUser", | ||
"qbusiness:DeleteGroup", | ||
"qbusiness:UpdateUser", | ||
"qbusiness:ListGroups"] | ||
Resource = [ | ||
"arn:aws:qbusiness:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:application/${awscc_qbusiness_application.example.id}", | ||
"arn:aws:qbusiness:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:application/${awscc_qbusiness_application.example.id}/index/${awscc_qbusiness_index.example.id}", | ||
"arn:aws:qbusiness:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:application/${awscc_qbusiness_application.example.id}/index/${awscc_qbusiness_index.example.id}/data-source/*" | ||
] | ||
} | ||
] | ||
}) | ||
} | ||
|
||
variable "bucket_name" { | ||
type = string | ||
description = "Name of the bucket to be used as the data source input" | ||
} | ||
|
||
data "aws_caller_identity" "current" {} | ||
|
||
data "aws_region" "current" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" | ||
subcategory: "" | ||
description: |- | ||
{{ .Description | plainmarkdown | trimspace | prefixlines " " }} | ||
--- | ||
|
||
# {{.Name}} ({{.Type}}) | ||
|
||
{{ .Description | trimspace }} | ||
|
||
## Example Usage | ||
|
||
### QBusiness data source of type S3 with the IAM role specifications for S3 access. | ||
|
||
{{ tffile (printf "examples/resources/%s/qbusiness_data_source.tf" .Name)}} | ||
|
||
{{ .SchemaMarkdown | trimspace }} | ||
{{- if .HasImport }} | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
{{ codefile "shell" .ImportFile }} | ||
|
||
{{- end }} |