Skip to content

Commit 3e10bb9

Browse files
authored
Merge pull request #2 from awsiv/terraform_registry
Release to terraform registry
2 parents ed1c4cb + 422e19d commit 3e10bb9

File tree

10 files changed

+244
-38
lines changed

10 files changed

+244
-38
lines changed

.github/workflows/main.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Unshallow
18+
run: git fetch --prune --unshallow
19+
- name: Set up Go
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.14
23+
- name: Test
24+
run: go test ./...
25+
- name: Import GPG key
26+
id: import_gpg
27+
uses: paultyng/[email protected]
28+
env:
29+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
30+
PASSPHRASE: ${{ secrets.PASSPHRASE }}
31+
- name: Run GoReleaser
32+
uses: goreleaser/goreleaser-action@v2
33+
with:
34+
version: latest
35+
args: release --rm-dist --skip-publish --snapshot
36+
env:
37+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Unshallow
15+
run: git fetch --prune --unshallow
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.14
20+
- name: Test
21+
run: go test ./...
22+
- name: Import GPG key
23+
id: import_gpg
24+
uses: paultyng/[email protected]
25+
env:
26+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
27+
PASSPHRASE: ${{ secrets.PASSPHRASE }}
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@v2
30+
with:
31+
version: latest
32+
args: release --rm-dist
33+
env:
34+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212
*.out
1313

1414
/dist
15+
vendor/*
16+
17+
terraform-provider-rdsdataservice

.goreleaser.yml

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,54 @@
1-
# This is an example goreleaser.yaml file with some sane defaults.
2-
# Make sure to check the documentation at http://goreleaser.com
1+
# Visit https://goreleaser.com for documentation on how to customize this
2+
# behavior.
33
before:
44
hooks:
5-
# you may remove this if you don't use vgo
6-
- go mod tidy
7-
# you may remove this if you don't need go generate
5+
- go mod download
86
- go generate ./...
97
builds:
10-
- env:
11-
- CGO_ENABLED=0
8+
- env:
9+
# goreleaser does not work with CGO, it could also complicate
10+
# usage by users in CI/CD systems like Terraform Cloud where
11+
# they are unable to install libraries.
12+
- CGO_ENABLED=0
13+
mod_timestamp: "{{ .CommitTimestamp }}"
14+
flags:
15+
- -trimpath
16+
ldflags:
17+
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}"
18+
goos:
19+
- linux
20+
- darwin
21+
goarch:
22+
- amd64
23+
ignore:
24+
- goos: darwin
25+
goarch: "386"
26+
binary: "{{ .ProjectName }}_v{{ .Version }}"
1227
archives:
13-
- replacements:
14-
darwin: Darwin
15-
linux: Linux
16-
windows: Windows
17-
386: i386
18-
amd64: x86_64
28+
- format: zip
29+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
1930
checksum:
20-
name_template: 'checksums.txt'
21-
snapshot:
22-
name_template: "{{ .Tag }}-next"
31+
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
32+
algorithm: sha256
33+
signs:
34+
- artifacts: checksum
35+
args:
36+
# if you are using this is a GitHub action or some other automated pipeline, you
37+
# need to pass the batch flag to indicate its not interactive.
38+
- "--batch"
39+
- "--local-user"
40+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
41+
- "--output"
42+
- "${signature}"
43+
- "--detach-sign"
44+
- "${artifact}"
45+
release:
46+
prerelease: auto
47+
# If you want to manually examine the release before its live, uncomment this line:
48+
# draft: true
2349
changelog:
2450
sort: asc
2551
filters:
2652
exclude:
27-
- '^docs:'
28-
- '^test:'
53+
- "^docs:"
54+
- "^test:"

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
# terraform-provider-rdsdataservice
2+
23
Manage Postgres db resources using the AWS Data API - Heavily inspired by [terraform-provider-postgresql](https://github.com/terraform-providers/terraform-provider-postgresql)
34

4-
[AWS Data API](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) allows us to run SQL using HTTP endpoint and AWS SDKs. This is awesome because it means that we no longer need to manage connections :).
5+
[AWS Data API](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) allows us to run SQL using HTTP endpoint and AWS SDK. This is awesome because it means that we no longer need to manage connections. This also uses secretsmanager secret so we no longer have to worry about secrets ending up in terraform state.
56

6-
I have tried to put together a PoC here. Since it uses AWS SDK, it might as well belong to terraform-provider-aws itself, but then, the CRUD operations are SQL statements instead of actual API calls - so maybe it has its own place? I am working on porting more resources and more importantly the acceptance tests. Let me know what you think about it :)
7+
Since it uses AWS SDK, it might as well belong to terraform-provider-aws itself, but then, the CRUD operations are SQL statements instead of actual API calls - so maybe it has its own place? I am working on porting more resources and more importantly the acceptance tests. Let me know what you think about it :)
78

89
API documentation: [package rdsdataservice](https://godoc.org/github.com/aws/aws-sdk-go/service/rdsdataservice)
910

10-
## Requirements ##
11+
## Requirements
12+
1113
Terraform 0.12+
1214
Go 1.13 (to build the provider plugin)
1315

14-
## Install ##
16+
## Install
1517

16-
You will need to install the binary as a [terraform third party plugin](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins). Terraform will then pick up the binary from the local filesystem when you run `terraform init`.
18+
You will need to install the binary as a [terraform third party plugin](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins). Terraform will then pick up the binary from the local filesystem when you run `terraform init`.
1719

1820
```sh
1921
curl -s https://raw.githubusercontent.com/awsiv/terraform-provider-rdsdataservice/master/install.sh | bash
2022
```
2123

22-
## Usage ##
24+
## Usage
2325

2426
```terraform
2527
provider "rdsdataservice" {

docs/index.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
page_title: "Provider: RDS DataService - DataAPI"
3+
---
4+
5+
# RDSDataService Provider
6+
7+
Manage Aurora Serverless databases with Terraform.
8+
9+
[AWS RDSDataService/Data API](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) allows us to run SQL using HTTP endpoint and AWS SDK.
10+
11+
Due to this, we have the following advantages:
12+
13+
- We no longer need to manage connections
14+
- We can use secretsmanager secret and not have to worry about secrets ending up in terraform state.
15+
16+
## Example Usage
17+
18+
```hcl
19+
provider "rdsdataservice" {
20+
version = "1.0.0"
21+
region = var.aws_region
22+
profile = var.aws_profile
23+
}
24+
25+
resource "rdsdataservice_postgres_database" "test" {
26+
name = "test"
27+
resource_arn = var.db_arn
28+
secret_arn = var.secret_arn
29+
owner = "postgres"
30+
}
31+
32+
resource "rdsdataservice_postgres_role" "test" {
33+
name = "test"
34+
resource_arn = var.db_arn
35+
secret_arn = var.secret_arn
36+
login = true
37+
}
38+
```
39+
40+
## Argument Reference
41+
42+
This provider is built to be compatible/similar to [terraform-provider-aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs), since it uses the AWS SDK and the provider implemenation is inspired by it.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
page_title: "rdsdataservice_postgres_database"
3+
---
4+
5+
# rdsdataservice_postgres_database Resource
6+
7+
Manage postgres databases
8+
9+
## Example Usage
10+
11+
```hcl
12+
resource "rdsdataservice_postgres_database" "test" {
13+
name = "test"
14+
resource_arn = var.db_arn
15+
secret_arn = var.secret_arn
16+
owner = "postgres"
17+
}
18+
```
19+
20+
## Argument Reference
21+
22+
- `name` - (Required) The PostgreSQL database name.
23+
- `resource_arn` - (Required) DB ARN.
24+
- `secret_arn` - (Required) DBA Secret ARN.
25+
- `owner` - (Optional) The ROLE which owns the database.. (Default: `postgres`)
26+
27+
## Attribute Reference
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
page_title: "rdsdataservice_postgres_role"
3+
---
4+
5+
# rdsdataservice_postgres_role Resource
6+
7+
Manage postgres roles
8+
9+
## Example Usage
10+
11+
```hcl
12+
resource "rdsdataservice_postgres_role" "test" {
13+
name = "test"
14+
resource_arn = var.db_arn
15+
secret_arn = var.secret_arn
16+
login = true
17+
}
18+
```
19+
20+
## Argument Reference
21+
22+
- `name` - (Required) The PostgreSQL database name to connect to.
23+
- `resource_arn` - (Required) DB ARN.
24+
- `secret_arn` - (Required) DBA Secret ARN.
25+
- `login` - (Optional) Determine whether a role is allowed to log in. (Default: `false`)
26+
- `inherit` - (Optional) Determine whether a role "inherits" the privileges of roles it is a member of. (Default: `true`)
27+
- `create_database` - (Optional) Define a role's ability to create databases. (Default: `false`)
28+
- `create_role` - (Optional) Determine whether this role will be permitted to create new roles. (Default: `false`)
29+
- `password` - (Optional) Set the role's password.
30+
- `roles` - (Optional) Role(s) to grant to this new role.
31+
- `superuser` - (Optional) Determine whether the new role is a "superuser". (Default: `false`)
32+
33+
## Attribute Reference

rdsdataservice/resource_rdsdataservice_postgres_database.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ func resourceAwsRdsdataservicePostgresDatabase() *schema.Resource {
2525
"name": {
2626
Type: schema.TypeString,
2727
Required: true,
28-
Description: "The PostgreSQL database name to connect to",
28+
Description: "Database name.",
2929
},
3030
"resource_arn": {
3131
Type: schema.TypeString,
3232
Required: true,
33-
Description: "The PostgreSQL database name to connect to",
33+
Description: "DB ARN.",
3434
},
3535
"secret_arn": {
3636
Type: schema.TypeString,
3737
Required: true,
38-
Description: "The PostgreSQL database name to connect to",
38+
Description: "DBA Secret ARN.",
3939
},
4040
"owner": {
4141
Type: schema.TypeString,
4242
Optional: true,
4343
Default: "postgres",
44-
Description: "The ROLE which owns the database",
44+
Description: "The ROLE which owns the database.",
4545
},
4646
},
4747
}

rdsdataservice/resource_rdsdataservice_postgres_role.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,62 +25,62 @@ func resourceAwsRdsdataservicePostgresRole() *schema.Resource {
2525
"name": {
2626
Type: schema.TypeString,
2727
Required: true,
28-
Description: "The PostgreSQL database name to connect to",
28+
Description: "The PostgreSQL database name to connect to.",
2929
},
3030
"login": {
3131
Type: schema.TypeBool,
3232
Optional: true,
3333
Default: false,
34-
Description: "Determine whether a role is allowed to log in",
34+
Description: "Determine whether a role is allowed to log in.",
3535
},
3636
"inherit": {
3737
Type: schema.TypeBool,
3838
Optional: true,
3939
Default: true,
40-
Description: `Determine whether a role "inherits" the privileges of roles it is a member of`,
40+
Description: `Determine whether a role "inherits" the privileges of roles it is a member of.`,
4141
},
4242
"create_database": {
4343
Type: schema.TypeBool,
4444
Optional: true,
4545
Default: false,
46-
Description: "Define a role's ability to create databases",
46+
Description: "Define a role's ability to create databases.",
4747
},
4848
"create_role": {
4949
Type: schema.TypeBool,
5050
Optional: true,
5151
Default: false,
52-
Description: "Determine whether this role will be permitted to create new roles",
52+
Description: "Determine whether this role will be permitted to create new roles.",
5353
},
5454
"password": {
5555
Type: schema.TypeString,
5656
Optional: true,
5757
Sensitive: true,
58-
Description: "Sets the role's password",
58+
Description: "Sets the role's password.",
5959
},
6060
"roles": {
6161
Type: schema.TypeSet,
6262
Optional: true,
6363
Elem: &schema.Schema{Type: schema.TypeString},
6464
Set: schema.HashString,
6565
MinItems: 0,
66-
Description: "Role(s) to grant to this new role",
66+
Description: "Role(s) to grant to this new role.",
6767
},
6868
"superuser": {
6969
Type: schema.TypeBool,
7070
Optional: true,
7171
Default: false,
72-
Description: `Determine whether the new role is a "superuser"`,
72+
Description: `Determine whether the new role is a "superuser".`,
7373
},
7474
"secret_arn": {
7575
Type: schema.TypeString,
7676
Required: true,
77-
Description: "The PostgreSQL database name to connect to",
77+
Description: "The PostgreSQL database name to connect to.",
7878
},
7979
"resource_arn": {
8080
Type: schema.TypeString,
8181
Optional: true,
8282
Default: "postgres",
83-
Description: "The PostgreSQL database name to connect to",
83+
Description: "The PostgreSQL database name to connect to.",
8484
},
8585
},
8686
}

0 commit comments

Comments
 (0)