-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add Google Spanner Support (google_spanner_database) #271
Add Google Spanner Support (google_spanner_database) #271
Conversation
91baff7
to
a6ac605
Compare
a6ac605
to
134534a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi again Nicki.
Thanks a lot for your contribution.
Just a few comments. Very good overall.
"ddl": &schema.Schema{ | ||
Type: schema.TypeList, | ||
Optional: true, | ||
ForceNew: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an update method for this. If you decide not to implement it in this PR, please file an issue and add a TODO here link to the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure an update makes sense here? My understanding is that the DDL update here is more additive style statements to apply to the database, rather than the definitive list of statements, i.e. could include update statements as well. Without support for clauses like DROP IF EXISTS
, this could be quite hard to make idempotent.
Moving from this:
resource "google_spanner_database" "db1" {
instance = "${google_spanner_instance.instance1.name}"
name = "mydb1"
ddl = [
"CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
"CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)"]
}
to this:
resource "google_spanner_database" "db1" {
instance = "${google_spanner_instance.instance1.name}"
name = "mydb1"
ddl = [
"CREATE TABLE t1 (t1 INT64 NOT NULL,) PRIMARY KEY(t1)",
"CREATE TABLE t2 (t2 INT64 NOT NULL,) PRIMARY KEY(t2)",
"CREATE TABLE t3 (t3 INT64 NOT NULL,) PRIMARY KEY(t3)"]
}
Would fail with an Error code 3 Duplicate name in schema: t1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. We should leave the ForceNew.
google/resource_spanner_database.go
Outdated
return handleNotFoundError(err, d, fmt.Sprintf("Spanner database %q", id.databaseUri())) | ||
} | ||
|
||
d.SetId(id.terraformId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to set the id here, it is set either in the create method or the import method.
|
||
## Attributes Reference | ||
|
||
No additional attributes are computed other than those defined above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add the computed state
field here once you added it.
Optional: true, | ||
ForceNew: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add the Computed
state field.
312fbef
to
7c72ab5
Compare
7c72ab5
to
ddbabb6
Compare
@rosbo Thanks again for review. Have made one comment re DDL update (see above). Rebased off the spanner-support-instance branch and made other changes as requested. Let me know if there is anything else that needs doing on this :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for adding Spanner support
make testacc TESTARGS="-run TestAccSpannerDatabase_" TEST="./google" |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
This PR aims to addresses #67 which looks to add Google Spanner Support, specifically adding a new resource google_spanner_database. CC @rileykarson @danawillow
In order to make these PR's easier to digest and review, instead of creating one big PR with all Spanner support in it, I have created one for each new resource to be added. This is the 2nd which adds support for the
google_spanner_database
resource. A separate one (PR #270) added the foundational support for creating the Instance, i.e. thegoogle_spanner_instance
resource.This PR does build off PR #270 as it uses the the
google_spanner_instance
resource so that should probably be reviewed first, then this one. Alternatively if you want to review all the Spanner support, this PR will have that.