Skip to content

Commit c0e431c

Browse files
authored
docs: add example for awscc_databrew_project (#2198)
* docs: add example for awscc_databrew_project * docs: remove extra line
1 parent 581c285 commit c0e431c

File tree

3 files changed

+215
-2
lines changed

3 files changed

+215
-2
lines changed

docs/resources/databrew_project.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
# generated by https://github.com/hashicorp/terraform-plugin-docs
32
page_title: "awscc_databrew_project Resource - terraform-provider-awscc"
43
subcategory: ""
54
description: |-
@@ -10,7 +9,103 @@ description: |-
109

1110
Resource schema for AWS::DataBrew::Project.
1211

13-
12+
## Example Usage
13+
14+
### DataBrew Project
15+
16+
Creates an AWS DataBrew project using an S3 source dataset, with necessary IAM roles and permissions to allow Databrew access to S3.
17+
18+
```terraform
19+
data "aws_caller_identity" "current" {}
20+
data "aws_region" "current" {}
21+
22+
# Create an S3 bucket for the DataBrew dataset
23+
resource "awscc_s3_bucket" "databrew_input" {
24+
bucket_name = "databrew-input-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}"
25+
26+
tags = [{
27+
key = "Modified By"
28+
value = "AWSCC"
29+
}]
30+
}
31+
32+
# Upload a sample CSV file to the bucket
33+
resource "aws_s3_object" "sample_data" {
34+
bucket = awscc_s3_bucket.databrew_input.id
35+
key = "input/sample.csv"
36+
content = "id,name,age\n1,John,30\n2,Jane,25"
37+
}
38+
39+
# Create the DataBrew dataset
40+
resource "awscc_databrew_dataset" "example" {
41+
name = "example-dataset"
42+
43+
input = {
44+
s3_input_definition = {
45+
bucket = awscc_s3_bucket.databrew_input.id
46+
key = aws_s3_object.sample_data.key
47+
}
48+
}
49+
50+
format = "CSV"
51+
format_options = {
52+
csv = {
53+
delimiter = ","
54+
header_row = true
55+
}
56+
}
57+
58+
tags = [{
59+
key = "Modified By"
60+
value = "AWSCC"
61+
}]
62+
}
63+
64+
# Create an IAM role to allow Databrew access to S3 Bucket
65+
resource "awscc_iam_role" "example" {
66+
assume_role_policy_document = jsonencode({
67+
Version = "2012-10-17"
68+
Statement = [
69+
{
70+
Action = "sts:AssumeRole"
71+
Effect = "Allow"
72+
Principal = {
73+
Service = "databrew.amazonaws.com"
74+
}
75+
},
76+
]
77+
})
78+
}
79+
80+
resource "awscc_iam_role_policy" "example" {
81+
role_name = awscc_iam_role.example.role_name
82+
policy_name = "example-policy"
83+
policy_document = jsonencode({
84+
Version = "2012-10-17"
85+
Statement = [
86+
{
87+
Action = [
88+
"s3:ListBucket",
89+
"s3:GetObject"
90+
]
91+
Effect = "Allow"
92+
Resource = [
93+
awscc_s3_bucket.databrew_input.arn,
94+
"${awscc_s3_bucket.databrew_input.arn}/*"
95+
]
96+
}
97+
]
98+
})
99+
}
100+
101+
# Create a DataBrew project
102+
resource "awscc_databrew_project" "example" {
103+
dataset_name = awscc_databrew_dataset.example.name
104+
name = "example-project"
105+
recipe_name = "example-recipe"
106+
role_arn = awscc_iam_role.example.arn
107+
}
108+
```
14109

15110
<!-- schema generated by tfplugindocs -->
16111
## Schema
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
data "aws_caller_identity" "current" {}
2+
data "aws_region" "current" {}
3+
4+
# Create an S3 bucket for the DataBrew dataset
5+
resource "awscc_s3_bucket" "databrew_input" {
6+
bucket_name = "databrew-input-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}"
7+
8+
tags = [{
9+
key = "Modified By"
10+
value = "AWSCC"
11+
}]
12+
}
13+
14+
# Upload a sample CSV file to the bucket
15+
resource "aws_s3_object" "sample_data" {
16+
bucket = awscc_s3_bucket.databrew_input.id
17+
key = "input/sample.csv"
18+
content = "id,name,age\n1,John,30\n2,Jane,25"
19+
}
20+
21+
# Create the DataBrew dataset
22+
resource "awscc_databrew_dataset" "example" {
23+
name = "example-dataset"
24+
25+
input = {
26+
s3_input_definition = {
27+
bucket = awscc_s3_bucket.databrew_input.id
28+
key = aws_s3_object.sample_data.key
29+
}
30+
}
31+
32+
format = "CSV"
33+
format_options = {
34+
csv = {
35+
delimiter = ","
36+
header_row = true
37+
}
38+
}
39+
40+
tags = [{
41+
key = "Modified By"
42+
value = "AWSCC"
43+
}]
44+
}
45+
46+
# Create an IAM role to allow Databrew access to S3 Bucket
47+
resource "awscc_iam_role" "example" {
48+
assume_role_policy_document = jsonencode({
49+
Version = "2012-10-17"
50+
Statement = [
51+
{
52+
Action = "sts:AssumeRole"
53+
Effect = "Allow"
54+
Principal = {
55+
Service = "databrew.amazonaws.com"
56+
}
57+
},
58+
]
59+
})
60+
}
61+
62+
resource "awscc_iam_role_policy" "example" {
63+
role_name = awscc_iam_role.example.role_name
64+
policy_name = "example-policy"
65+
policy_document = jsonencode({
66+
Version = "2012-10-17"
67+
Statement = [
68+
{
69+
Action = [
70+
"s3:ListBucket",
71+
"s3:GetObject"
72+
]
73+
Effect = "Allow"
74+
Resource = [
75+
awscc_s3_bucket.databrew_input.arn,
76+
"${awscc_s3_bucket.databrew_input.arn}/*"
77+
]
78+
}
79+
]
80+
})
81+
}
82+
83+
# Create a DataBrew project
84+
resource "awscc_databrew_project" "example" {
85+
dataset_name = awscc_databrew_dataset.example.name
86+
name = "example-project"
87+
recipe_name = "example-recipe"
88+
role_arn = awscc_iam_role.example.arn
89+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
3+
subcategory: ""
4+
description: |-
5+
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
6+
---
7+
8+
# {{.Name}} ({{.Type}})
9+
10+
{{ .Description | trimspace }}
11+
12+
## Example Usage
13+
14+
### DataBrew Project
15+
16+
Creates an AWS DataBrew project using an S3 source dataset, with necessary IAM roles and permissions to allow Databrew access to S3.
17+
18+
{{ tffile (printf "examples/resources/%s/main.tf" .Name)}}
19+
20+
{{ .SchemaMarkdown | trimspace }}
21+
{{- if .HasImport }}
22+
23+
## Import
24+
25+
Import is supported using the following syntax:
26+
27+
{{ codefile "shell" .ImportFile }}
28+
29+
{{- end }}

0 commit comments

Comments
 (0)