-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alloydbomni): add service and dependant resources
- Loading branch information
Showing
20 changed files
with
2,936 additions
and
30 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
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
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
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
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
192 changes: 192 additions & 0 deletions
192
internal/sdkprovider/service/alloydbomni/alloydbomni.go
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,192 @@ | ||
package alloydbomni | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
"github.com/aiven/terraform-provider-aiven/internal/schemautil" | ||
) | ||
|
||
func aivenAlloyDBOmniSchema() map[string]*schema.Schema { | ||
s := schemautil.ServiceCommonSchemaWithUserConfig(schemautil.ServiceTypeAlloyDBOmni) | ||
s[schemautil.ServiceTypeAlloyDBOmni] = &schema.Schema{ | ||
Type: schema.TypeList, | ||
MaxItems: 1, | ||
Computed: true, | ||
Description: "Values provided by the AlloyDB Omni server.", | ||
Optional: true, | ||
Sensitive: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
// TODO: Remove `uri` in the next major version. | ||
"uri": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "AlloyDB Omni primary connection URI.", | ||
Optional: true, | ||
Sensitive: true, | ||
}, | ||
"uris": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "AlloyDB Omni primary connection URIs.", | ||
Optional: true, | ||
Sensitive: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
Sensitive: true, | ||
}, | ||
}, | ||
"bouncer": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "PgBouncer connection details for [connection pooling](https://aiven.io/docs/products/postgresql/concepts/pg-connection-pooling).", | ||
Deprecated: "This field was added by mistake and has never worked. It will be removed in future versions.", | ||
}, | ||
// TODO: Remove `host` in the next major version. | ||
"host": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni primary node host IP or name.", | ||
}, | ||
// TODO: Remove `port` in the next major version. | ||
"port": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni port.", | ||
}, | ||
// TODO: Remove `sslmode` in the next major version. | ||
"sslmode": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni SSL mode setting.", | ||
}, | ||
// TODO: Remove `user` in the next major version. | ||
"user": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni admin user name.", | ||
}, | ||
// TODO: Remove `password` in the next major version. | ||
"password": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "AlloyDB Omni admin user password.", | ||
Sensitive: true, | ||
}, | ||
// TODO: Remove `dbname` in the next major version. | ||
"dbname": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "Primary AlloyDB Omni database name.", | ||
}, | ||
"params": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "AlloyDB Omni connection parameters.", | ||
Optional: true, | ||
Sensitive: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"host": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni host IP or name.", | ||
}, | ||
"port": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni port.", | ||
}, | ||
"sslmode": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni SSL mode setting.", | ||
}, | ||
"user": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni admin user name.", | ||
}, | ||
"password": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "AlloyDB Omni admin user password.", | ||
}, | ||
"database_name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "Primary AlloyDB Omni database name.", | ||
}, | ||
}, | ||
}, | ||
}, | ||
"replica_uri": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "AlloyDB Omni replica URI for services with a replica.", | ||
Sensitive: true, | ||
}, | ||
"standby_uris": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "AlloyDB Omni standby connection URIs.", | ||
Optional: true, | ||
Sensitive: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
Sensitive: true, | ||
}, | ||
}, | ||
"syncing_uris": { | ||
Type: schema.TypeList, | ||
Computed: true, | ||
Description: "AlloyDB Omni syncing connection URIs.", | ||
Optional: true, | ||
Sensitive: true, | ||
Elem: &schema.Schema{ | ||
Type: schema.TypeString, | ||
Sensitive: true, | ||
}, | ||
}, | ||
// TODO: This isn't in the connection info, but it's in the metadata. | ||
// We should move this to the other part of the schema in the next major version. | ||
"max_connections": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
Sensitive: true, | ||
Description: "The [number of allowed connections](https://aiven.io/docs/products/postgresql/reference/pg-connection-limits). Varies based on the service plan.", | ||
}, | ||
}, | ||
}, | ||
} | ||
return s | ||
} | ||
|
||
func ResourceAlloyDBOmni() *schema.Resource { | ||
return &schema.Resource{ | ||
Description: "Creates and manages an Aiven for AlloyDB Omni service.", | ||
CreateContext: schemautil.ResourceServiceCreateWrapper(schemautil.ServiceTypeAlloyDBOmni), | ||
ReadContext: schemautil.ResourceServiceRead, | ||
UpdateContext: schemautil.ResourceServiceUpdate, | ||
DeleteContext: schemautil.ResourceServiceDelete, | ||
CustomizeDiff: schemautil.CustomizeDiffGenericService(schemautil.ServiceTypeAlloyDBOmni), | ||
Importer: &schema.ResourceImporter{ | ||
StateContext: schema.ImportStatePassthroughContext, | ||
}, | ||
Timeouts: schemautil.DefaultResourceTimeouts(), | ||
Schema: aivenAlloyDBOmniSchema(), | ||
SchemaVersion: 1, | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
internal/sdkprovider/service/alloydbomni/alloydbomni_data_source.go
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,15 @@ | ||
package alloydbomni | ||
|
||
import ( | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
"github.com/aiven/terraform-provider-aiven/internal/schemautil" | ||
) | ||
|
||
func DatasourceAlloyDBOmni() *schema.Resource { | ||
return &schema.Resource{ | ||
ReadContext: schemautil.DatasourceServiceRead, | ||
Description: "Gets information about an Aiven for AlloyDB Omni service.", | ||
Schema: schemautil.ResourceSchemaAsDatasourceSchema(aivenAlloyDBOmniSchema(), "project", "service_name"), | ||
} | ||
} |
Oops, something went wrong.