diff --git a/docs/_index.md b/docs/_index.md new file mode 100644 index 00000000..de1cd174 --- /dev/null +++ b/docs/_index.md @@ -0,0 +1,5 @@ +--- +title: Aiven +meta_desc: The Aiven provider for Pulumi can be used to provision any of the cloud resources available in Aiven. +layout: package +--- diff --git a/docs/installation-configuration.md b/docs/installation-configuration.md new file mode 100644 index 00000000..1f78b11a --- /dev/null +++ b/docs/installation-configuration.md @@ -0,0 +1,103 @@ +--- +title: Aiven Provider for Pulumi Installation & Configuration +meta_desc: Provides an overview on how to configure the Pulumi Aiven Provider for Pulumi. +layout: package +--- +## Installation + +The aiven provider is available as a package in all Pulumi languages: + +* JavaScript/TypeScript: [`@pulumi/aiven`](https://www.npmjs.com/package/@pulumi/aiven) +* Python: [`pulumi-aiven`](https://pypi.org/project/pulumi-aiven/) +* Go: [`github.com/pulumi/pulumi-aiven/sdk/v6/go/aiven`](https://github.com/pulumi/pulumi-aiven) +* .NET: [`Pulumi.Aiven`](https://www.nuget.org/packages/Pulumi.Aiven) +* Java: [`com.pulumi/aiven`](https://central.sonatype.com/artifact/com.pulumi/aiven) + +The Pulumi provider for [Aiven](https://aiven.io/), the trusted open source data platform for everyone. +## Authentication +Sign up for Aiven and [create a personal token](https://aiven.io/docs/platform/howto/create_authentication_token). + +You can also create an [application user](https://aiven.io/docs/platform/howto/manage-application-users) and use its token for accessing the Aiven Provider. +## Example usage + +{{< chooser language "typescript,python,go,csharp,java,yaml" >}} +{{% choosable language typescript %}} +```yaml +# Pulumi.yaml provider configuration file +name: configuration-example +runtime: nodejs +config: + aiven:apiToken: + value: 'TODO: var.aiven_api_token' + +``` + +{{% /choosable %}} +{{% choosable language python %}} +```yaml +# Pulumi.yaml provider configuration file +name: configuration-example +runtime: python +config: + aiven:apiToken: + value: 'TODO: var.aiven_api_token' + +``` + +{{% /choosable %}} +{{% choosable language csharp %}} +```yaml +# Pulumi.yaml provider configuration file +name: configuration-example +runtime: dotnet +config: + aiven:apiToken: + value: 'TODO: var.aiven_api_token' + +``` + +{{% /choosable %}} +{{% choosable language go %}} +```yaml +# Pulumi.yaml provider configuration file +name: configuration-example +runtime: go +config: + aiven:apiToken: + value: 'TODO: var.aiven_api_token' + +``` + +{{% /choosable %}} +{{% choosable language yaml %}} +```yaml +# Pulumi.yaml provider configuration file +name: configuration-example +runtime: yaml +config: + aiven:apiToken: + value: 'TODO: var.aiven_api_token' + +``` + +{{% /choosable %}} +{{% choosable language java %}} +```yaml +# Pulumi.yaml provider configuration file +name: configuration-example +runtime: java +config: + aiven:apiToken: + value: 'TODO: var.aiven_api_token' + +``` + +{{% /choosable %}} +{{< /chooser >}} +## Environment variables + +* For authentication, you can set the `AIVEN_TOKEN` to your token value. +* To use beta resources, set `PROVIDER_AIVEN_ENABLE_BETA` to any value. +* To allow IP filters to be purged, set `AIVEN_ALLOW_IP_FILTER_PURGE` to any value. This feature prevents accidental purging of IP filters, which can cause you to lose access to services. +## Resource options +The list of options in this document is not comprehensive. However, most map directly to the [Aiven REST API](https://api.aiven.io/doc/) properties. \ No newline at end of file diff --git a/provider/resources.go b/provider/resources.go index 220a1c8e..e918eafb 100644 --- a/provider/resources.go +++ b/provider/resources.go @@ -17,8 +17,10 @@ package aiven import ( "context" "fmt" + "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen" "os" "path/filepath" + "regexp" "unicode" // embed is used to store bridge-metadata.json in the compiled binary @@ -98,6 +100,7 @@ func Provider(ctx context.Context) tfbridge.ProviderInfo { UpstreamRepoPath: "./upstream", Version: version.Version, MetadataInfo: tfbridge.NewProviderMetadata(metadata), + DocRules: &tfbridge.DocRuleInfo{EditRules: docEditRules}, Config: map[string]*tfbridge.SchemaInfo{ "api_token": {Secret: tfbridge.True()}, }, @@ -229,5 +232,45 @@ func Provider(ctx context.Context) tfbridge.ProviderInfo { return prov } +func docEditRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit { + return append( + defaults, + removeTFAndLater, + skipWarningSection, + skipExamplesSection, + ) +} + +// Removes a "Warnings" section that includes TF-specific recommendations +var skipWarningSection = tfbridge.DocsEdit{ + Path: "index.md", + Edit: func(_ string, content []byte) ([]byte, error) { + return tfgen.SkipSectionByHeaderContent(content, func(headerText string) bool { + return headerText == "Warning" + }) + }, +} + +// Removes a section containing TF-specific tutorial links. +// This is *not* the "Example Usage" section, and doesn't actually contain any code examples. +var skipExamplesSection = tfbridge.DocsEdit{ + Path: "index.md", + Edit: func(_ string, content []byte) ([]byte, error) { + return tfgen.SkipSectionByHeaderContent(content, func(headerText string) bool { + return headerText == "Examples" + }) + }, +} + +// Removes a reference to TF version and compatibility +var TFVersionOrLaterRegexp = regexp.MustCompile(`(?s)For [tT]erraform v[0-9]+\.?[0-9]?\.?[0-9]? and later:`) +var removeTFAndLater = tfbridge.DocsEdit{ + Path: "index.md", + Edit: func(_ string, content []byte) ([]byte, error) { + content = TFVersionOrLaterRegexp.ReplaceAllLiteral(content, nil) + return content, nil + }, +} + //go:embed cmd/pulumi-resource-aiven/bridge-metadata.json var metadata []byte