Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "Pulumi Builder",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/guiyomh/features/golangci-lint:0": {},
"ghcr.io/devcontainers/features/dotnet:2": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers-community/npm-features/typescript:1": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/jungaretti/features/make:1": {},
"ghcr.io/flexwie/devcontainer-features/pulumi:1": {},
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}
},
"customizations": {
"vscode": {
"extensions": [
"DavidAnson.vscode-markdownlint",
"bierner.markdown-preview-github-styles",
"esbenp.prettier-vscode",
"ms-vscode.makefile-tools",
"golang.go",
"github.vscode-github-actions",
"pulumi.pulumi-lsp-client"
]
}
},
"postCreateCommand": "${PWD}/.devcontainer/setup.sh"
}
97 changes: 97 additions & 0 deletions .devcontainer/setup.sh
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea of using setup.sh instead of a custom image that you want to pull the latest version every time? Or why not use a custom image?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think it worth the effort to put that script into a whole separate custom feature. It's not likely to be very helpful to more than a small set of people. The postCreateCommand is usually either a bunch of commands strung together for repo specific setup, or in a separate script, which I prefer from a readability standpoint.

As for using a custom image, I think defeats the purpose of using devcontainer. This way, we can rebuild the devcontainer with the option to ignore the cache, and the base image and the feature layers get updated to what's current. If we used a custom image, there would be the need to keep it updated, hosting it, and so on.

Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env bash

set -eEo pipefail

# Create a temporary directory to download pulumictl
download_dir=$(mktemp -d)

# Cleanup function to remove the temporary directory
cleanup() {
local dir="${1}"
echo "Cleaning up download destination directory ${dir}"
rm -rf "${dir}"
}

# Set up trap to call cleanup on exit
trap 'cleanup "${download_dir}"' EXIT

# Function to get the latest release tag from pulumi/pulumictl
get_latest_pulumictl_release() {
local arch="${1:-amd64}"
local os="${2:-linux}"
curl -s https://api.github.com/repos/pulumi/pulumictl/releases/latest | \
jq -r '.assets[] |
select(.browser_download_url |
test("pulumictl-.*'"${os}-${arch}"'.tar.gz")) |
.browser_download_url'
}

# Function to download the latest pulumictl release for a given OS and arch
# Usage: download_pulumictl_release <destination_dir> <os> <arch>
download_pulumictl_release() {
local dest_dir="$1"
local arch="${2:-amd64}"
local os="${3:-linux}"
local url
local filename

filename="pulumictl-${os}-${arch}.tar.gz"

url=$(get_latest_pulumictl_release "${arch}" "${os}")
if [[ -z "$url" ]]; then
echo "No pulumictl release found for ${os} ${arch}"
return 1
fi

mkdir -p "${dest_dir}"
echo "Downloading pulumictl ${url} for ${os} ${arch}"
curl -s -L "${url}" -o "${dest_dir}/${filename}"
echo "Downloaded pulumictl to ${dest_dir}/${filename}"
}

get_os() {
local os
os=$(uname -s)
case $os in
Linux) echo "linux";;
Darwin) echo "darwin";;
*) echo "Unsupported OS: ${os}" >&2 ; return 1;;
esac
}

get_arch() {
local arch
arch=$(uname -m)
case $arch in
x86_64) echo "amd64";;
aarch64 | arm64) echo "arm64";;
*) echo "Unsupported architecture: ${arch}" >&2 ; return 1;;
esac
}

install_pulumictl() {
local dest_dir="${1}"
local os
local arch
local filename

if [[ -z "${dest_dir}" ]]; then
echo "Destination directory is required"
return 1
fi

os=$(get_os) || return 1
arch=$(get_arch) || return 1

download_pulumictl_release "${dest_dir}" "${arch}" "${os}"

filename="pulumictl-${os}-${arch}.tar.gz"
echo "Extracting ${filename} to ${dest_dir}"
tar -xzf "${dest_dir}/${filename}" -C "${dest_dir}"
sudo mv "${dest_dir}/pulumictl" "/usr/local/bin/pulumictl"
sudo chmod +x "/usr/local/bin/pulumictl"
echo "Installed pulumictl to /usr/local/bin/pulumictl"
}

# Install pulumictl
install_pulumictl "${download_dir}"
108 changes: 99 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,111 @@ Do you want to hack on Pulumi? Awesome! We are so happy to have you.
Please refer to the [main Pulumi repo](https://github.com/pulumi/pulumi/)'s [CONTRIBUTING.md file](
https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md) for details on how to do so.

## Prerequisites

- Go 1.24 or later
- Node.js 18 or later
- Python 3.7 or later
- .NET SDK 6.0 or later
- [`pulumictl`](https://github.com/pulumi/pulumictl)

This repository includes a config to setup a [devcontainer](https://containers.dev/), which will
setup an environment with all necessary requirements installed.

## Committing Generated Code

Code generated for Pulumi SDKs should be checked in as part of the pull request containing a
particular change. To generate code after making changes, run `make` from the root of this
particular change. To generate code after making changes, run `make build` from the root of this
repository.

If a large number of seemingly-unrelated diffs are produced by `make` (for example, lots of changes
to comments unrelated to the change you are making), ensure that the latest dependencies for the
provider are installed by running `make ensure` in the root of the repository.
## Building the Provider

The provider is generated from the Event Store Cloud Terraform provider. To build the Pulumi provider
and generate SDKs:

1. Ensure you're in the development container
2. Run the following command to build all SDKs:

```bash
make build
```

This will:

- Build the provider binary
- Generate SDKs for Node.js, Python, Go, and .NET

## Manual Testing

> [!IMPORTANT]
> This will create and destroy **real** Kurrent Cloud resources

To test your changes before committing them:

1. Build the provider using the [steps above](#building-the-provider)
2. Install the provider locally:

```bash
pulumi plugin install resource eventstorecloud --file bin/pulumi-resource-eventstorecloud
```

3. Temporarily set the version in the TypeScript SDKs `package.json`

```bash
sed -i 's/${VERSION}/0.0.1-dev/' sdk/nodejs/package.json
```

4. Login to Pulumi locally to prevent being prompted to login to the hosted service

```bash
pulumi login --local
```

5. Change directory to the test project

```bash
cd test
```

6. Install the local version of the TypeScript SDK

```bash
yarn add @eventstore/pulumi-eventstorecloud@file:../sdk/nodejs
```

7. Create a new stack

```bash
PULUMI_CONFIG_PASSPHRASE=very-secure-passphrase pulumi stack init -s dev
```

8. Set config values

```bash
pulumi config set eventstorecloud:organizationId <ORG_ID>
pulumi config set eventstorecloud:token <ACCESS_TOKEN> --secret
```

9. Create the stack

```bash
pulumi up -y
```

10. Once you're done, clean up resources and revert the change to `package.json`

```bash
PULUMI_CONFIG_PASSPHRASE=very-secure-passphrase pulumi destroy -y &&
pulumi stack rm dev -y &&
cd .. && sed -i 's/0.0.1-dev/${VERSION}/' sdk/nodejs/package.json
```

## Running Integration Tests
## Publishing a New Release

The examples and integration tests in this repository will create and destroy real AWS
cloud resources while running. Before running these tests, make sure that you have
[configured Pulumi with AWS](https://pulumi.io/install/aws.html) successfully once before.
Once all changes have been merged to the `main` branch and you're ready to cut a new release, all
that needs to be done is to create a new tag using semver format, e.g. v0.2.21.

_TODO: Add any steps you need to take to run integration tests here_
Once the tag has been pushed to the Github repo, an action will be triggered. This will create new a
new Github release with the binary artifacts, as well as publish the release to NPM and Nuget.

The provider docs in the Pulumi Package Registry will be updated automatically sometime later.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ lint_provider:: provider # lint the provider code
cleanup:: # cleans up the temporary directory
rm -r $(WORKING_DIR)/bin
rm -f provider/cmd/${PROVIDER}/schema.go
rm -rf node_modules nuget

help::
@grep '^[^.#]\+:\s\+.*#' Makefile | \
Expand All @@ -111,10 +112,11 @@ help::

clean::
rm -rf sdk/{dotnet,nodejs,go,python}
rm -rf test/node_modules

install_plugins::
[ -x $(shell which pulumi) ] || curl -fsSL https://get.pulumi.com | sh
pulumi plugin install resource random 4.6.0
pulumi plugin install resource random

install_dotnet_sdk::
mkdir -p $(WORKING_DIR)/nuget
Expand All @@ -131,4 +133,3 @@ install_sdks:: install_dotnet_sdk install_python_sdk install_nodejs_sdk

test::
cd examples && go test -v -tags=all -parallel ${TESTPARALLELISM} -timeout 2h

50 changes: 28 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pulumi provider for Event Store Cloud
# Pulumi provider for Kurrent Cloud (formerly Event Store Cloud)

The Event Store Cloud provider allows you to manage resources in [Event Store Cloud](https://eventstore.com/cloud).
The `eventstorecloud` provider allows you to manage resources in [Kurrent Cloud](https://www.kurrent.io/kurrent-cloud).

## Installing

Expand All @@ -12,47 +12,53 @@ For projects that use .NET and Go Pulumi SDK you have to install the provider be

Use the following command to add the plugin to your environment:

```
pulumi plugin install resource eventstorecloud [version] \
--server https://github.com/EventStore/pulumi-eventstorecloud/releases/download/[version]
```

Example:

```
pulumi plugin install resource eventstorecloud v0.2.3 \
--server https://github.com/EventStore/pulumi-eventstorecloud/releases/download/v0.2.7
```bash
pulumi plugin install resource eventstorecloud --server github://api.github.com/kurrent-io
```

### Configuration

The following configuration points are available for the `eventstorecloud` provider:
The following configuration options are required for the `eventstorecloud` provider:

- `eventstorecloud:organizationId` - the organization ID for an existing organization in Event Store Cloud
- `eventstorecloud:token` - a valid refresh token for an Event Store Cloud account with admin access to the organization

Alternatively, these values can be set via the `ESC_ORG_ID` and `ESC_TOKEN` environment variables.

### Node.js (Java/TypeScript)

To use from JavaScript or TypeScript in Node.js, install using either `npm`:

$ npm install @eventstore/pulumi-eventstorecloud
```bash
npm install @eventstore/pulumi-eventstorecloud
```

or `yarn`:

$ yarn add @eventstore/pulumi-eventstorecloud
```bash
yarn add @eventstore/pulumi-eventstorecloud
```

### .NET
### Go

Add the NuGet package `Pulumi.EventStoreCloud` to your Pulumi project, which uses the .NET Pulumi SDK.
To use from Go, use `go get` to grab the latest version of the library

### Python
```bash
go get github.com/EventStore/pulumi-eventstorecloud/sdk/go/eventstorecloud
```

[WIP]
### .NET

### Go
To use from .NET, install using `dotnet add package`:

To use from Go, use `go get` to grab the latest version of the library
```bash
dotnet add package Pulumi.EventStoreCloud
```

### Python

\[WIP]

$ go get github.com/EventStore/pulumi-eventstorecloud/sdk/go/eventstorecloud
## Reference

For detailed reference documentation, please visit [the Pulumi registry](https://www.pulumi.com/registry/packages/eventstorecloud/).
10 changes: 10 additions & 0 deletions test/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: esc-test
description: esc-test
runtime:
name: nodejs
options:
packagemanager: npm
config:
pulumi:tags:
value:
pulumi:template: typescript
Loading