Skip to content

Commit

Permalink
Goreleaser + installer + readme update + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bishwa Shrestha committed Dec 2, 2019
1 parent cb97407 commit c71eb0b
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 174 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

/dist
28 changes: 28 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
# you may remove this if you don't use vgo
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# terraform-provider-rdsdataservice
Manage Postgres db resources using the AWS Data API - Heavily inspired by terraform-provider-postgresql
Manage Postgres db resources using the AWS Data API - Heavily inspired by [terraform-provider-postgresql] (https://github.com/terraform-providers/terraform-provider-postgresql)

## Requirements ##
Terraform 0.12+
Go 1.13 (to build the provider plugin)

## Install ##

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`.

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

## Usage ##

```terraform
provider "rdsdataservice" {
version = "1.0.0"
region = var.aws_region
profile = var.aws_profile
}
resource "rdsdataservice_postgres_database" "test" {
name = "test"
resource_arn = var.db_arn
secret_arn = var.secret_arn
owner = "postgres"
}
resource "rdsdataservice_postgres_role" "test" {
name = "test"
resource_arn = var.db_arn
secret_arn = var.secret_arn
login = true
}
```
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ go 1.13

require (
github.com/aws/aws-sdk-go v1.25.43
github.com/blang/semver v3.5.1+incompatible
github.com/hashicorp/aws-sdk-go-base v0.4.0
github.com/hashicorp/errwrap v1.0.0
github.com/hashicorp/terraform v0.12.16
github.com/hashicorp/terraform-plugin-sdk v1.4.0
github.com/lib/pq v1.0.0
github.com/mitchellh/go-homedir v1.1.0
Expand Down
174 changes: 11 additions & 163 deletions go.sum

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
arch=$(uname -m)
case $arch in
x86_64)
ARCH=amd64
;;
i386)
ARCH=386
;;
*)
echo "no build for this architecture: $arch"
exit 1
esac

kernel=$(uname -s)
if [ $kernel != "Darwin" ] && [ $kernel != "Linux" ]; then
echo "no build for this kernel: $kernel"
exit 1
fi

kernel_lower=$(echo $kernel | tr "[:upper:]" "[:lower:]")
terraform_plugins="$HOME/.terraform.d/plugins/${kernel_lower}_$ARCH/"

# IFS= preserve newlines
IFS= manifest=$(curl -s https://api.github.com/repos/awsiv/terraform-provider-rdsdataservice/releases/latest)

url=$(echo $manifest \
| grep "browser_download_url.*${kernel}_${arch}" \
| cut -d '"' -f 4 \
)
version=$(echo $manifest \
| grep tag_name \
| cut -d '"' -f 4 \
)

if [ -z ${url} ]; then
echo "no build for this kernel/arch: ${kernel}_${arch}"
exit 1
fi

dest_file="terraform-provider-rdsdataservice_$version"
curl $url -L -o $dest_file
chmod +x $dest_file

mkdir -p $terraform_plugins
mv $dest_file $terraform_plugins/

4 changes: 4 additions & 0 deletions publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version=v1.0.0
git tag -a $version -m $version
git push origin $version
goreleaser release --rm-dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"text/template"

"github.com/terraform-providers/terraform-provider-rdsdataservice/rdsdataservice/internal/keyvaluetags"
"github.com/awsiv/terraform-provider-rdsdataservice/rdsdataservice/internal/keyvaluetags"
)

const filename = `list_tags_gen.go`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"text/template"

"github.com/terraform-providers/terraform-provider-rdsdataservice/rdsdataservice/internal/keyvaluetags"
"github.com/awsiv/terraform-provider-rdsdataservice/rdsdataservice/internal/keyvaluetags"
)

const filename = `service_tags_gen.go`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"text/template"

"github.com/terraform-providers/terraform-provider-rdsdataservice/rdsdataservice/internal/keyvaluetags"
"github.com/awsiv/terraform-provider-rdsdataservice/rdsdataservice/internal/keyvaluetags"
)

const filename = `update_tags_gen.go`
Expand Down
8 changes: 4 additions & 4 deletions rdsdataservice/resource_rdsdataservice_postgres_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/lib/pq"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
)

var objectTypes = map[string]string{
Expand Down Expand Up @@ -52,10 +51,11 @@ func resourceAwsRdsdataservicePostgresGrant() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
/*ValidateFunc: validation.StringInSlice([]string{
"table",
"sequence",
}, false),
*/
Description: "The PostgreSQL object type to grant the privileges on (one of: table, sequence)",
},
"privileges": &schema.Schema{
Expand Down Expand Up @@ -112,7 +112,7 @@ func resourceAwsRdsdataservicePostgresGrantCreate(d *schema.ResourceData, meta i
}

sql = fmt.Sprintf(
"GRANT %s ON ALL %sS IN SCHEMA %s TO %s",
"GRANT %s ON ALL %s IN SCHEMA %s TO %s",
strings.Join(privileges, ","),
strings.ToUpper(d.Get("object_type").(string)),
pq.QuoteIdentifier(d.Get("schema").(string)),
Expand All @@ -129,7 +129,7 @@ func resourceAwsRdsdataservicePostgresGrantCreate(d *schema.ResourceData, meta i
_, err = rdsdataserviceconn.ExecuteStatement(&createOpts)

if err != nil {
return fmt.Errorf("Error granting priviliges: %s to %s: %#v", grantingRole, d.Get("name").(string), err)
return fmt.Errorf("Error granting priviliges: %s to %s: %#v", strings.Join(privileges, ","), d.Get("name").(string), err)
}

d.SetId(generateGrantID(d))
Expand Down

0 comments on commit c71eb0b

Please sign in to comment.