diff --git a/.ci-mgmt.yaml b/.ci-mgmt.yaml new file mode 100644 index 0000000..0d4e56d --- /dev/null +++ b/.ci-mgmt.yaml @@ -0,0 +1,11 @@ +# Required values: +provider: zia # substitute the name of your provider, without the pulumi- prefix +#env: # A map of required configuration for any integration tests, etc. +# AN_OPTION: value +# ANOTHER_OPTION: true + # etc. +lint: true # Linting should be true in most cases, unless failing rules in the upstream provider makes this impractical. + +# Optional values: +#docker: true # Whether the provider's tests use Docker to run. If set to true, a file `testing/docker-compose.yml` must be present in the provider repository. +#setup-script: testing/setup.sh # Path to a script that's used for testing bootstraps \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..c23b1a3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,68 @@ +ARG UBUNTU_VERSION=latest +FROM ubuntu:${UBUNTU_VERSION} + +# Update apt-get and install various needed utilities +RUN apt-get update && \ + apt-get install -y curl && \ + apt-get install -y wget && \ + apt-get install -y xz-utils && \ + apt-get install -y make && \ + apt-get install -y gcc && \ + apt-get install -y git + +# Install bridged provider prerequisites +# See README.md + +# Install go +ARG GO_VERSION=1.18.3 +RUN rm -rf /usr/local/go && \ + wget -O ${GO_VERSION}.tar.gz https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ + tar -C /usr/local -xzf ${GO_VERSION}.tar.gz && \ + rm ${GO_VERSION}.tar.gz + +ENV GOPATH=/root/go +ENV PATH=$PATH:/usr/local/go/bin + +# Install go linter +RUN mkdir -p $GOPATH/bin && \ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.46.2 + +ENV PATH=$PATH:$GOPATH/bin + +# Install pulumictl +ARG PULUMICTL_VERSION=v0.0.32 +RUN rm -rf /usr/local/bin/pulumictl && \ + wget -O pulumictl.${PULUMICTL_VERSION}.tar.gz https://github.com/pulumi/pulumictl/releases/download/${PULUMICTL_VERSION}/pulumictl-${PULUMICTL_VERSION}-linux-amd64.tar.gz && \ + tar -C /usr/local/bin -xzf pulumictl.${PULUMICTL_VERSION}.tar.gz + +# Install nodejs +ARG NODEJS_VERSION=v16.16.0 +ARG NODEJS_PKG=node-${NODEJS_VERSION}-linux-x64 +ARG NODEJS_TARBALL=${NODEJS_PKG}.tar.xz +RUN rm -rf /usr/local/node && \ + wget -O ${NODEJS_TARBALL} https://nodejs.org/dist/${NODEJS_VERSION}/${NODEJS_TARBALL} && \ + tar -C /usr/local -xf ${NODEJS_TARBALL} && \ + mv /usr/local/${NODEJS_PKG} /usr/local/node + +ENV PATH=$PATH:/usr/local/node/bin + +# Install yarn +RUN npm install --global yarn + +# Install python and related items +RUN apt-get install -y python3 && \ + apt-get install -y python3-setuptools + +# Install .NET +RUN wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \ + dpkg -i packages-microsoft-prod.deb && \ + rm packages-microsoft-prod.deb + +RUN apt-get update && \ + apt-get install -y apt-transport-https && \ + apt-get update && \ + apt-get install -y dotnet-sdk-6.0 + +# Install Pulumi +RUN curl -fsSL https://get.pulumi.com | sh +ENV PATH=$PATH:/root/.pulumi/bin diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..6b9e8cb --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,8 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.3/containers/hugo +{ + "name": "TFProvider", + "build": { + "dockerfile": "Dockerfile" + } +} \ No newline at end of file diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a1e6d07 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +/.github/ @willguibr \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..a2245f4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: +- package-ecosystem: gomod + directory: "/provider" + schedule: + interval: monthly + open-pull-requests-limit: 3 + reviewers: + - willguibr +- package-ecosystem: gomod + directory: "/sdk" + schedule: + interval: monthly + open-pull-requests-limit: 3 + reviewers: + - willguibr \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..19403cb --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ +## Affected Components +* [ ] Resources +* [ ] Test +* [ ] Docs +* [ ] Tooling +* [ ] Other + +## Pre-Requisites +* [ ] Go code is formatted with `go fmt` + + +## Notes for the Reviewer + + +> Resolves #[issue-number] + +## New Dependency Submission + \ No newline at end of file diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..fb467dd --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,21 @@ +daysUntilStale: 90 +daysUntilClose: 7 +exemptLabels: + - "status: confirmed" + - "type: question" + +staleLabel: "status: stale" +issues: + markComment: > + This issue has been automatically marked as stale. + **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. + We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! + closeComment: > + Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! +pulls: + markComment: > + This pull request has been automatically marked as stale. + **If this pull request is still relevant, please leave any comment** (for example, "bump"), and we'll keep it open. + We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. + closeComment: > + Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you! \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..395ef8e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,145 @@ +name: release + +on: + push: + tags: + - v*.*.* + +permissions: + contents: write + id-token: write + +env: + PROVIDER: zia + DOTNETVERSION: | + 6.0.x + 3.1.301 + GOVERSION: 1.21.x + JAVAVERSION: "11" + NODEVERSION: 20.x + PYTHONVERSION: "3.9" + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NUGET_PUBLISH_KEY: ${{ secrets.NUGET_PUBLISH_KEY }} + NUGET_FEED_URL: https://api.nuget.org/v3/index.json + PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} + PULUMI_API: https://api.pulumi.com + PULUMI_GO_DEP_ROOT: ${{ github.workspace }}/.. + PULUMI_LOCAL_NUGET: ${{ github.workspace }}/nuget + PULUMI_TEST_OWNER: "zscaler" + PYPI_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + PYPI_USERNAME: __token__ + PUBLISH_PYPI: true + PUBLISH_NPM: true + PUBLISH_NUGET: true + ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }} + ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }} + ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }} + ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }} + TRAVIS_OS_NAME: linux + +jobs: + publish_binary: + name: publish + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v4.1.1 + - name: Install Go + uses: actions/setup-go@v4.1.0 + with: + go-version: ${{env.GOVERSION}} + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.10.0 + with: + repo: pulumi/pulumictl + - name: Set PreRelease Version + run: echo "GORELEASER_CURRENT_TAG=v$(pulumictl get version --language generic)" >> $GITHUB_ENV + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5.0.0 + with: + args: -p 3 release --rm-dist + version: latest + - name: Create tag + uses: actions/github-script@v6.4.1 + with: + script: | + github.rest.git.createRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'refs/tags/sdk/${{ github.ref_name }}', + sha: context.sha + }) + strategy: + fail-fast: true + + publish_sdk: + name: Publish SDKs + runs-on: ubuntu-latest + needs: publish_binary + steps: + - name: Checkout Repo + uses: actions/checkout@v4.1.1 + # - name: Unshallow clone for tags + # run: git fetch --prune --unshallow --tags + - name: Install Go + uses: actions/setup-go@v4.1.0 + with: + go-version: ${{ env.GOVERSION }} + - name: Install pulumictl + uses: jaxxstorm/action-install-gh-release@v1.10.0 + with: + repo: pulumi/pulumictl + - name: Install Pulumi CLI + uses: pulumi/actions@v4 + - name: Setup Node + uses: actions/setup-node@v3.8.2 + with: + node-version: ${{ env.NODEVERSION }} + - name: Setup DotNet + uses: actions/setup-dotnet@v2.1.1 + with: + dotnet-version: ${{ env.DOTNETVERSION }} + - name: Setup Python + uses: actions/setup-python@v4.7.1 + with: + python-version: ${{ env.PYTHONVERSION }} + - name: Build SDK + run: make build_${{ matrix.language }} + # - name: Check worktree clean + # run: | + # git update-index -q --refresh + # if ! git diff-files --quiet; then + # >&2 echo "error: working tree is not clean, aborting!" + # git status + # git diff + # exit 1 + # fi + - if: ${{ matrix.language == 'python' && env.PUBLISH_PYPI == 'true' }} + name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.10 + with: + user: ${{ env.PYPI_USERNAME }} + password: ${{ env.PYPI_PASSWORD }} + packages_dir: ${{github.workspace}}/sdk/python/bin/dist + - if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }} + uses: JS-DevTools/npm-publish@v2.2.2 + with: + access: "public" + token: ${{ env.NPM_TOKEN }} + package: ${{github.workspace}}/sdk/nodejs/bin/package.json + provenance: true + - if: ${{ matrix.language == 'dotnet' && env.PUBLISH_NUGET == 'true' }} + name: publish nuget package + run: | + dotnet nuget push ${{github.workspace}}/sdk/dotnet/bin/Debug/*.nupkg -s ${{ env.NUGET_FEED_URL }} -k ${{ env.NUGET_PUBLISH_KEY }} + echo "done publishing packages" + strategy: + fail-fast: true + matrix: + language: + - nodejs + - python + - dotnet + - go \ No newline at end of file diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml new file mode 100644 index 0000000..20df569 --- /dev/null +++ b/.github/workflows/upgrade.yml @@ -0,0 +1,20 @@ +name: Upgrade provider + +on: + workflow_dispatch: + schedule: + - cron: 0 5 * * * + +jobs: + upgrade_provider: + name: upgrade-provider + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + issues: write + steps: + - name: Call upgrade provider action + uses: pulumi/pulumi-upgrade-provider-action@v0.0.11 + env: + GH_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..507f6d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +.idea +.code +**/vendor/ +.pulumi +**/bin/ +**/obj/ +Pulumi.*.yaml +**/node_modules/ +.DS_Store + +**/command-output/ + +.idea/ +*.iml + +yarn.lock +**/pulumiManifest.go + +ci-scripts +provider/**/schema-embed.json +**/version.txt +**/nuget +**/dist +zia_all_together +local_dev +.trash diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..6258f1f --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,23 @@ +linters: + enable: + - deadcode + - errcheck + - goconst + - gofmt + - golint + - gosec + - govet + - ineffassign + - interfacer + - megacheck + - misspell + - nakedret + - structcheck + - unconvert + - varcheck + enable-all: false +run: + skip-files: + - schema.go + - pulumiManifest.go + timeout: 10m \ No newline at end of file diff --git a/.goreleaser.prerelease.yml b/.goreleaser.prerelease.yml new file mode 100644 index 0000000..67ebe34 --- /dev/null +++ b/.goreleaser.prerelease.yml @@ -0,0 +1,30 @@ +archives: +- id: archive + name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}' +before: + hooks: + - make provider +builds: +- binary: pulumi-resource-zia + dir: provider + env: + - CGO_ENABLED=0 + - GO111MODULE=on + goarch: + - amd64 + - arm64 + goos: + - darwin + - windows + - linux + ldflags: + - -s + - -w + - -X github.com/zscaler/pulumi-zia/provider/pkg/version.Version={{.Tag}} + main: ./cmd/pulumi-resource-zia/ +changelog: + skip: true +release: + disable: true +snapshot: + name_template: '{{ .Tag }}-SNAPSHOT' \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..da718b1 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,30 @@ +archives: +- id: archive + name_template: '{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}' +before: + hooks: + - make provider +builds: +- binary: pulumi-resource-zia + dir: provider + env: + - CGO_ENABLED=0 + - GO111MODULE=on + goarch: + - amd64 + - arm64 + goos: + - darwin + - windows + - linux + ldflags: + - -s + - -w + - -X github.com/zscaler/pulumi-zia/provider/pkg/version.Version={{.Tag}} + main: ./cmd/pulumi-resource-zia/ +changelog: + skip: true +release: + disable: false +snapshot: + name_template: '{{ .Tag }}-SNAPSHOT' \ No newline at end of file diff --git a/.pulumi-java-gen.version b/.pulumi-java-gen.version new file mode 100644 index 0000000..6f060dc --- /dev/null +++ b/.pulumi-java-gen.version @@ -0,0 +1 @@ +0.9.9 \ No newline at end of file diff --git a/.upgrade-config.yml b/.upgrade-config.yml new file mode 100644 index 0000000..b2bff83 --- /dev/null +++ b/.upgrade-config.yml @@ -0,0 +1 @@ +upstream-provider-name: terraform-provider-zia \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..424fce7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +## 0.0.1 (March 27, 2024) + +### Notes + +- Release date: **(March 27, 2024)** + +🎉 **Initial Release** 🎉 diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md new file mode 100644 index 0000000..bfb1c21 --- /dev/null +++ b/CODE-OF-CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at code-of-conduct@pulumi.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..eea090e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,36 @@ +# Contributing to the Pulumi ecosystem + +Do you want to contribute to Pulumi? Awesome! We are so happy to have you. +We have a few tips and housekeeping items to help you get up and running. + +## Code of Conduct + +Please make sure to read and observe our [Code of Conduct](./CODE-OF-CONDUCT.md) + +## Community Expectations + +Please read about our [contribution guidelines here.](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md#communications) + +## Setting up your development environment + +### Pulumi prerequisites + +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#developing) for details on how to get set up with Pulumi. + +## Committing Generated Code + +You must generate and check in the SDKs on each pull request containing a code change, e.g. adding a new resource to `resources.go`. + +1. Run `make build_sdks` from the root of this repository +1. Open a pull request containing all changes +1. *Note:* If a large number of seemingly-unrelated diffs are produced by `make build_sdks` (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 `go mod tidy` in the `provider/` directory of this repository. + +## Running Integration Tests + +The examples and integration tests in this repository will create and destroy real +cloud resources while running. Before running these tests, make sure that you have +configured access to your cloud provider with Pulumi. + +_TODO: Add any steps you need to take to run integration tests here_ + diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..7f75e1e --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,11 @@ +Except as otherwise noted below and/or in individual files, this +project is licensed under the Apache License, Version 2.0 (see +LICENSE or ). + +This project is a larger work that combines with software written +by third parties, licensed under their own terms. + +Notably, this larger work combines with the Terraform AWS Provider, +which is licensed under the Mozilla Public License 2.0 (see + or the project itself at +). diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0fc3a4a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 [Zscaler](https://github.com/zscaler) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..648cd9e --- /dev/null +++ b/Makefile @@ -0,0 +1,129 @@ +PACK := zia +ORG := zscaler +PROJECT := github.com/${ORG}/pulumi-${PACK} +NODE_MODULE_NAME := @bdzscaler/${PACK} +TF_NAME := ${PACK} +PROVIDER_PATH := provider +VERSION_PATH := ${PROVIDER_PATH}/pkg/version.Version +JAVA_GEN := pulumi-java-gen +JAVA_GEN_VERSION := v0.9.4 +PLUGIN_PATH := ${HOME}/.pulumi/plugins/ + +TFGEN := pulumi-tfgen-${PACK} +PROVIDER := pulumi-resource-${PACK} +VERSION := $(shell pulumictl get version) + +TESTPARALLELISM := 10 + +WORKING_DIR := $(shell pwd) + +.PHONY: development provider build_sdks build_nodejs build_dotnet build_go build_python + +development:: install_plugins provider lint_provider build_sdks build_java # Build the provider & SDKs for a development environment + +# Required for the codegen action that runs in pulumi/pulumi and pulumi/pulumi-terraform-bridge +build:: install_plugins provider build_sdks install_sdks +only_build:: build + +tfgen:: install_plugins + (cd provider && go build -a -o $(WORKING_DIR)/bin/${TFGEN} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${TFGEN}) + $(WORKING_DIR)/bin/${TFGEN} schema --out provider/cmd/${PROVIDER} + (cd provider && VERSION=$(VERSION) go generate cmd/${PROVIDER}/main.go) + +provider:: tfgen install_plugins # build the provider binary + (cd provider && go build -a -o $(WORKING_DIR)/bin/${PROVIDER} -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" ${PROJECT}/${PROVIDER_PATH}/cmd/${PROVIDER}) + +build_sdks:: install_plugins provider build_nodejs build_python build_go build_dotnet # build_java # build all the sdks + +build_nodejs:: VERSION := $(shell pulumictl get version --language javascript) +build_nodejs:: install_plugins tfgen # build the node sdk + $(WORKING_DIR)/bin/$(TFGEN) nodejs --overlays provider/overlays/nodejs --out sdk/nodejs/ + cd sdk/nodejs/ && \ + yarn install && \ + yarn run tsc && \ + cp ../../README.md ../../LICENSE package.json yarn.lock ./bin/ && \ + sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json + +build_python:: PYPI_VERSION := $(shell pulumictl get version --language python) +build_python:: install_plugins tfgen # build the python sdk + $(WORKING_DIR)/bin/$(TFGEN) python --overlays provider/overlays/python --out sdk/python/ + cd sdk/python/ && \ + cp ../../README.md . && \ + python3 setup.py clean --all 2>/dev/null && \ + rm -rf ./bin/ ../python.bin/ && cp -R . ../python.bin && mv ../python.bin ./bin && \ + sed -i.bak -e 's/^VERSION = .*/VERSION = "$(PYPI_VERSION)"/g' -e 's/^PLUGIN_VERSION = .*/PLUGIN_VERSION = "$(VERSION)"/g' ./bin/setup.py && \ + rm ./bin/setup.py.bak && \ + cd ./bin && python3 setup.py build sdist + +build_go:: install_plugins tfgen # build the go sdk + $(WORKING_DIR)/bin/$(TFGEN) go --overlays provider/overlays/go --out sdk/go/ + +build_dotnet:: DOTNET_VERSION := $(shell pulumictl get version --language dotnet) +build_dotnet:: install_plugins tfgen # build the dotnet sdk + pulumictl get version --language dotnet + $(WORKING_DIR)/bin/$(TFGEN) dotnet --overlays provider/overlays/dotnet --out sdk/dotnet/ + cd sdk/dotnet/ && \ + echo "${DOTNET_VERSION}" >version.txt && \ + dotnet build /p:Version=${DOTNET_VERSION} + +build_go:: install_plugins tfgen # build the go sdk + $(WORKING_DIR)/bin/$(TFGEN) go --overlays provider/overlays/go --out sdk/go/ + +build_java:: PACKAGE_VERSION := $(shell pulumictl get version --language generic) +build_java:: bin/pulumi-java-gen + $(PLUGIN_PATH)/language-java-$(JAVA_GEN_VERSION)/$(JAVA_GEN) generate --schema provider/cmd/$(PROVIDER)/schema.json --out sdk/java --build gradle-nexus + cd sdk/java/ && \ + echo "module fake_java_module // Exclude this directory from Go tools\n\ngo 1.17" > go.mod && \ + gradle --console=plain build + +bin/pulumi-java-gen:: + $(pulumi plugin install language java ${JAVA_GEN_VERSION}) + +lint_provider:: provider # lint the provider code + cd provider && golangci-lint run -c ../.golangci.yml + +cleanup:: # cleans up the temporary directory + rm -r $(WORKING_DIR)/bin + rm -f provider/cmd/${PROVIDER}/schema.go + +help:: + @grep '^[^.#]\+:\s\+.*#' Makefile | \ + sed "s/\(.\+\):\s*\(.*\) #\s*\(.*\)/`printf "\033[93m"`\1`printf "\033[0m"` \3 [\2]/" | \ + expand -t20 + +clean:: + rm -rf sdk/{dotnet,nodejs,go,python} + +install_plugins:: + [ -x $(shell which pulumi) ] || curl -fsSL https://get.pulumi.com | sh + pulumi plugin install resource random 4.8.2 + pulumi plugin install resource aws 5.11.0 + +install_dotnet_sdk:: + mkdir -p $(WORKING_DIR)/nuget + find . -name '*.nupkg' -print -exec cp -p {} ${WORKING_DIR}/nuget \; + +install_python_sdk:: + +install_go_sdk:: + +install_nodejs_sdk:: + yarn link --cwd $(WORKING_DIR)/sdk/nodejs/bin + +install_java_sdk:: + +install_sdks:: install_dotnet_sdk install_python_sdk install_nodejs_sdk + +test:: + cd examples && go test -v -tags=all -parallel ${TESTPARALLELISM} -timeout 2h + +.PHONY: check-dirty +check-dirty: tfgen build_sdks ## Verifies that source tree is not dirty + @git add . + @if test -n "`git status --porcelain`"; then echo "Source tree is dirty"; git status; exit 1 ; fi + @git add . + + +release-notes: + mkdir -p $(ARTIFACTS) + @ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef669e5 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# Zscaler Internet Access (ZIA) Resource Provider + +The ZIA Resource Provider lets you manage [ZIA](http://github.com/zscaler/pulumi-zia) resources. To use +this package, please [install the Pulumi CLI first](https://pulumi.com/). + +## Installing + +This package is available for several languages/platforms: + +### Node.js (JavaScript/TypeScript) + +To use from JavaScript or TypeScript in Node.js, install using either `npm`: + +```bash +npm install @bdzscaler/pulumi-zia +``` + +or `yarn`: + +```bash +yarn add @bdzscaler/pulumi-zia +``` + +### Python + +To use from Python, install using `pip`: + +```bash +pip install zscaler-pulumi-zia +``` + +### Go + +To use from Go, use `go get` to grab the latest version of the library: + +```bash +go get github.com/zscaler/pulumi-zia/sdk/go/... +``` + +### .NET + +To use from .NET, install using `dotnet add package`: + +```bash +dotnet add package zscaler.PulumiPackage.Zia +``` + +## Configuration + +The following configuration points are available for the `zia` provider: + +- `zia:username` (client id: `ZIA_USERNAME`) - (Required) This is the API username to interact with the ZIA cloud. +- `zia:password` (client secret: `ZIA_PASSWORD`) - (Required) This is the password for the API username to authenticate in the ZIA cloud. +- `zia:api_key` (customer id: `ZIA_API_KEY`) - (Required) This is the API Key used in combination with the ``username`` and ``password`` +- `zia:zia_cloud` (cloud environment: `ZIA_CLOUD`) - (Required) The cloud name where the ZIA tenant is hosted. The supported values are: + - ``zscaler`` + - ``zscalerone`` + - ``zscalertwo`` + - ``zscalerthree`` + - ``zscloud`` + - ``zscalerbeta`` + - ``zscalergov`` + +## Reference + +For detailed reference documentation, please visit [the Pulumi registry](https://www.pulumi.com/registry/packages/zia/api-docs/). + +## Support + +This template/solution are released under an as-is, best effort, support +policy. These scripts should be seen as community supported and Zscaler +Business Development Team will contribute our expertise as and when possible. +We do not provide technical support or help in using or troubleshooting the components +of the project through our normal support options such as Zscaler support teams, +or ASC (Authorized Support Centers) partners and backline +support options. The underlying product used (Zscaler Internet Access API) by the +scripts or templates are still supported, but the support is only for the +product functionality and not for help in deploying or using the template or +script itself. Unless explicitly tagged, all projects or work posted in our +GitHub repository at () or sites other +than our official Downloads page on +are provided under the best effort policy. diff --git a/assets/zscaler.png b/assets/zscaler.png new file mode 100644 index 0000000..bccecc3 Binary files /dev/null and b/assets/zscaler.png differ diff --git a/assets/zscaler.svg b/assets/zscaler.svg new file mode 100644 index 0000000..150015d --- /dev/null +++ b/assets/zscaler.svg @@ -0,0 +1 @@ + diff --git a/docs/_index.md b/docs/_index.md new file mode 100644 index 0000000..52f7269 --- /dev/null +++ b/docs/_index.md @@ -0,0 +1,99 @@ +--- +title: Zscaler Internet Access (ZIA) +meta_desc: Provides an overview of the ZIA Provider for Pulumi. +layout: overview +--- + +The Zscaler Internet Access (ZIA) provider for Pulumi can be used to provision any of the cloud resources available in [Zscaler Internet Access](https://help.zscaler.com/zia). +The ZIA provider must be configured with credentials to deploy and update resources in the ZIA Cloud. + +## Example + +{{< chooser language "typescript,python,go,csharp" >}} +{{% choosable language typescript %}} + +```typescript +import * as zia from "@bdzscaler/pulumi-zia"; +const staticIP = new zia.ZIATrafficForwardingStaticIP("static_ip_example", { + comment: "Pulumi Traffic Forwarding Static IP", + geoOverride: true, + ipAddress: "123.234.244.245", + latitude: -36.848461, + longitude: 174.763336, + routableIp: true, +}); +``` + +{{% /choosable %}} +{{% choosable language python %}} + +```python +import zscaler_pulumi_zia as zia + +staticIP = zia.ZIATrafficForwardingStaticIPArgs("static_ip_example", + comment="Pulumi Traffic Forwarding Static IP", + geoOverride=True, + routableIp=True, + ipAddress="123.234.244.245", + latitude=-36.848461, + longitude=174.763336, +) +``` + +{{% /choosable %}} +{{% choosable language go %}} + +```go +import ( + "github.com/pulumi/pulumi/sdk/v3/go/pulumi" + zia "github.com/zscaler/pulumi-zia/sdk/go/zia" +) + +func main() { + pulumi.Run(func(ctx *pulumi.Context) error { + staticIP, err := zia.NewZIATrafficForwardingStaticIP(ctx, "static_ip_example", &zia.ZIATrafficForwardingStaticIPArgs{ + Comment: pulumi.String("Pulumi Traffic Forwarding Static IP"), + RoutableIp: pulumi.Bool(true), + GeoOverride: pulumi.Bool(true), + IpAddress: pulumi.String("123.234.244.245"), + Latitude: pulumi.Float64Ptr(37.3382082), + Longitude: pulumi.Float64Ptr(-121.8863286), + }) + if err != nil { + return fmt.Errorf("error creating zia static ip: %v", err) + } + + ctx.Export("staticIP", staticIP.IpAddress) + + return nil + }) +} +``` + +{{% /choosable %}} +{{% choosable language csharp %}} + +```csharp + using System.Collections.Generic; + using Pulumi; + using zia = zscaler.PulumiPackage.Zia; + + return await Deployment.RunAsync(() => + { + // ZIA Traffic Forwarding - Static IP + var example = new zia.ZIATrafficForwardingStaticIP("static_ip_example", new() + { + Comment = "Pulumi Traffic Forwarding Static IP", + GeoOverride = true, + RoutableIp = true, + IpAddress = "123.234.244.245", + Latitude = -36.848461, + Longitude = 174.763336, + }); + + }); +``` + +{{% /choosable %}} + +{{< /chooser >}} diff --git a/docs/installation-configuration.md b/docs/installation-configuration.md new file mode 100644 index 0000000..2e5177c --- /dev/null +++ b/docs/installation-configuration.md @@ -0,0 +1,82 @@ +--- +title: ZIA Setup +meta_desc: Information on how to install the ZIA provider. +layout: installation +--- + +## Installation + +The Pulumi ZIA provider is available as a package in all Pulumi languages: + +* JavaScript/TypeScript: [`@bdzscaler/pulumi-zia`](https://www.npmjs.com/package/@zscaler/pulumi-zia) +* Python: [`zscaler_pulumi_zia`](https://pypi.org/project/zscaler-pulumi-zia/) +* Go: [`github.com/zscaler/pulumi-zia/sdk/go/zia`](https://pkg.go.dev/github.com/zscaler/pulumi-zia/sdk) +* .NET: [`zscaler.PulumiPackage.Zia`](https://www.nuget.org/packages/zscaler.PulumiPackage.Zia) + +### Provider Binary + +The ZIA provider binary is a third party binary. It can be installed using the `pulumi plugin` command. + +```bash +pulumi plugin install resource zia --server github://api.github.com/zscaler +``` + +Replace the version string with your desired version. + +## Setup + +To provision resources with the Pulumi ZIA provider, you need to have ZIA credentials. Zscaler maintains documentation on how to create API keys [here](https://help.zscaler.com/zia/getting-started-zia-api) + +### Set environment variables + +Once you have provisioned these credentials, you can set environment variables to provision resources in ZIA: + +{{< chooser os "linux,macos,windows" >}} +{{% choosable os linux %}} + +```bash +$ export ZIA_USERNAME= +$ export ZIA_PASSWORD= +$ export ZIA_API_KEY= +$ export ZIA_CLOUD= +``` + +{{% /choosable %}} + +{{% choosable os macos %}} + +```bash +$ export ZIA_USERNAME= +$ export ZIA_PASSWORD= +$ export ZIA_API_KEY= +$ export ZIA_CLOUD= +``` + +{{% /choosable %}} + +{{% choosable os windows %}} + +```powershell +> $env:ZIA_USERNAME = "" +> $env:ZIA_PASSWORD = "" +> $env:ZIA_API_KEY = "" +> $env:ZIA_CLOUD = "" +``` + +{{% /choosable %}} +{{< /chooser >}} + +## Configuration Options + +Use `pulumi config set zia: