Giter Club home page Giter Club logo

automation-api-examples's Introduction

automation-api-examples

This repo provides full end to end examples and walk-throughs for the Pulumi Automation API. The Automation API is available for Go, Node.js, Python and C#.

Full docs for automation API can be found here:

Content

Take a look at our examples grouped by language.

Go Examples

Example Description
Git Repo Use Automation API with a Pulumi program from a git repo. In this case a static S3 website from the Pulumi examples repo.
Inline Program Use Automation API with an inline Pulumi program. Inline programs are self contained in a single main.go and support full debugging capabilities. In this demo we deploy the same static S3 website adapted from the Pulumi examples repo.
Local Program This example shows how to use Automation API with an existing traditional CLI-driven Pulumi program. We add an Automation API deployment program to our Fargate program that deploys a web service via a Fargate task behind a load balancer.
Inline/Local Hybrid Program This example shows how to refactor your infrastructure to get the best of both worlds, a debuggable inline program that can still be driven by the Pulumi CLI for convenience (one-off deployments, inspecting the stack, retrieving outputs, etc). In this example we deploy an S3 static website. The automation/main.go is fully debuggable, including the shared deployment function. The stack can also be managed via the CLI program in cli/main.go.
Multi-Stack Orchestration This example shows how to use Automation API to tame the complexity of multiple stacks with dependent stack outputs. We decompose our S3 static website into two stacks, one that manages the bucket, and another that manages the index.html file. Both of these are defined as inline programs, and are deployed and destroyed together via a single main.go
Pulumi Over HTTP - Infra as RESTful resources This application demonstrates how to run Automation API in an HTTP server to expose infrastructure as RESTful resources. In our case, we've defined and exposed a static website site that exposes all of the CRUD operations plus list. Users can hit our REST endpoint and create custom static websites by specifying the content field in the POST body. All of our infrastructure is defined in inline programs that are constructed and altered on the fly based on input parsed from user-specified POST bodies.
Database Migration This example provisions an AWS Aurora SQL database and executes a database "migration" using the resulting connection info. This migration creates a table, inserts a few rows of data, and reads the data back to verify the setup. This is all done in a single program using an inline Pulumi program. With Automation API you can orchestrate complex workflows that go beyond infrastructure provisioning and into application management, database setup, etc.
Cloud-backed Secret Provider This example demonstrates an inline program using a cloud-backed (KMS) secret provider.
Passphrase Secret Provider This example demonstrates an inline program using a passphrase secret provider.
Remote Deployment This example demonstrates how to use Automation API to run Pulumi programs remotely with Pulumi Deployments. In this case a static S3 website from the Pulumi examples repo.

Node.js Examples

Example Toolchain Description
Inline Program Typescript + ts-node Use Automation API with an inline Pulumi program. Inline programs are self-contained in a single index.ts and support full debugging capabilities. In this demo we deploy the same static S3 website adapted from the Pulumi examples repo. This example uses typescript with ts-node as an execution environment.
Inline Program Typescript (tsc) + node Use Automation API with an inline Pulumi program. Inline programs are self-contained in a single index.ts and support full debugging capabilities. In this demo we deploy the same static S3 website adapted from the Pulumi examples repo. This example uses typescript compiled into javascript via tsc and executed via node.
Inline Program Javascript + node Use Automation API with an inline Pulumi program. Inline programs are self-contained in a single index.js and support full debugging capabilities. In this demo we deploy the same static S3 website adapted from the Pulumi examples repo. This example uses plain javascript executed via node.
Local Program Typescript + ts-node This example shows how to use Automation API with an existing traditional CLI-driven Pulumi program. We add an Automation API deployment program to our existing CLI-driven S3 website program. This example uses typescript with ts-node as an execution environment.
Cross-Language Program Typescript + ts-node This example shows how to use Automation API in typescript with an existing traditional CLI-driven Pulumi program written in a different language, in this case go. We add an Automation API deployment program to our Fargate program that deploys a web service via a Fargate task behind a load balancer. This automation program uses typescript with ts-node as an execution environment.
Pulumi Over HTTP - Infra as RESTful resources Typescript (tsc) + node This application demonstrates how to run Automation API in an HTTP server to expose infrastructure as RESTful resources. In our case, we've defined and exposed a static website site that exposes all of the CRUD operations plus list. Users can hit our REST endpoint and create custom static websites by specifying the content field in the POST body. All of our infrastructure is defined in inline programs that are constructed and altered on the fly based on input parsed from user specified POST bodies.
Database Migration Typescript (tsc) + node This example provisions an AWS Aurora SQL database and executes a database "migration" using the resulting connection info. This migration creates a table, inserts a few rows of data, and reads the data back to verify the setup. This is all done in a single program using an inline Pulumi program. With Automation API you can orchestrate complex workflows that go beyond infrastructure provisioning and into application management, database setup, etc.
Local Program with mocha tests Typescript + ts-node This example shows how to use Automation API with an existing traditional CLI-driven Pulumi program alongside some mocha-based integration tests to ensure that the infrastructure was set up properly. This example uses typescript with ts-node as an execution environment, with mocha being used to run the tests.
Remote Deployment Typescript + ts-node This example demonstrates how to use Automation API to run Pulumi programs remotely with Pulumi Deployments. In this case a static S3 website from the Pulumi examples repo.

Python Examples

Example Description
Inline Program Use Automation API with an inline Pulumi program. Inline programs are self contained in a single main.py and support full debugging capabilities. In this demo we deploy the same static S3 website adapted from the Pulumi examples repo.
Cross-Language Program This example shows how to use Automation API in python with an existing traditional CLI-driven Pulumi program written in a different language, in this case go. We add an Automation API deployment program to our Fargate program that deploys a web service via a Fargate task behind a load balancer.
Database Migration This example provisions an AWS Aurora SQL database and executes a database "migration" using the resulting connection info. This migration creates a table, inserts a few rows of data, and reads the data back to verify the setup. This is all done in a single program using an inline Pulumi program. With Automation API you can orchestrate complex workflows that go beyond infrastructure provisioning and into application management, database setup, etc.
Local Program This example shows how to use Automation API with an existing traditional CLI-driven Pulumi program. We add an Automation API deployment program to our existing CLI-driven app described in the aws-py-voting-app example.
Pulumi Over HTTP - Infra as RESTful resources This application demonstrates how to run Automation API in an HTTP server to expose infrastructure as RESTful resources. In our case, we've defined and exposed a static website site that exposes all of the CRUD operations plus list. Users can hit our REST endpoint and create custom static websites by specifying the content field in the POST body. All of our infrastructure is defined in inline programs that are constructed and altered on the fly based on input parsed from user specified POST bodies.
Pulumi Via Jupyter This example explores running Pulumi through a Jupyter Notebook.
Remote Deployment This example demonstrates how to use Automation API to run Pulumi programs remotely with Pulumi Deployments. In this case a static S3 website from the Pulumi examples repo.

.NET Examples

Example Description
Inline Program Use Automation API with an inline Pulumi program. Inline programs are self contained in a .NET console application and support full debugging capabilities. In this demo we deploy the same static S3 website adapted from the Pulumi examples repo.
Local Program This example shows how to use Automation API with an existing traditional CLI-driven Pulumi program. We add an Automation API deployment program to our existing CLI-driven S3 website program.
Cross-Language Program This example shows how to use Automation API in dotnet with an existing traditional CLI-driven Pulumi program written in a different language, in this case go. We add an Automation API deployment program to our Fargate program that deploys a web service via a Fargate task behind a load balancer.
Database Migration This example provisions an AWS Aurora SQL database and executes a database "migration" using the resulting connection info. This migration creates a table, inserts a few rows of data, and reads the data back to verify the setup. This is all done in a single program using an inline Pulumi program. With Automation API you can orchestrate complex workflows that go beyond infrastructure provisioning and into application management, database setup, etc.
Remote Deployment This example demonstrates how to use Automation API to run Pulumi programs remotely with Pulumi Deployments. In this case a static S3 website from the Pulumi examples repo.

Other projects using Automation API

Project Description
Ploy Ploy is a CLI used to deploy a local Docker image to an EKS cluster.
Halloumi Pulumi + Heroku = Halloumi. You write your application, we run it in the cloud.
Self Service Platyform A webapp skeleton for building your own Infrastructure Platform using Python and Flask.

If you have a project using Automation API that you'd like to showcase here please submit a PR!

automation-api-examples's People

Contributors

alex0m avatar alexmikhalev avatar clstokes avatar devsunb avatar dixler avatar emctl avatar evanboyle avatar julienp avatar justinvp avatar komalali avatar maxalexson avatar mikhailshilkov avatar mitchellgerdisch avatar orionstudt avatar pierskarsenbarg avatar spara avatar stack72 avatar vipentti avatar zaid-ajaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

automation-api-examples's Issues

Example with remote state

Hello! I think all examples use a local state file... I I'm not sure, are remote state backends supported at all? It would be super useful to have an example πŸ™‡ Thanks a lot, the automation API seems super interesting πŸš€

1. Roll back option, 2. convert Output<T> to T, 3. wait then resume, 4. Remove randomness

Four questions

  1. Is there auto-roll back option in pulumi? if xyz resource isn't found or created can we auto roll back all resources in stack?

  2. can we convert pulimi.IDOutput to string and *string?

  3. I am creating EC2 machine and right after that I am running ansible. But the problem is machine state gets to β€œrunning” after some time and due to that ansible fails to reach the server. Is there await or anything in native pulumi as an option while creating EC2?
    I know we can add our own custom loop and check state of the machine and then continue but I want to try pulumi option if available.

  4. I noticed pulumi randomly starts executing code in deployfunc of automation api. Is there a way I can remove it and make it to execute code from top to bottom?
    I know about dependson option, but it executes print statements before resource creation as well which I want to avoid and execute the code from top to bottom.

P.S: I am using Golang.

main tests are red

What happened?

pulumi program is not downloading the correct provider plugin

Diagnostics:
  pulumi:providers:aws (default_4_38_1):
    error: no resource plugin 'aws-v4.38.1' found in the workspace or on your $PATH, install the plugin using `pulumi plugin install resource aws v4.38.1`
 
Resources:
    + 1 created

Duration: 1s

Unhandled exception. Pulumi.Automation.Commands.Exceptions.CommandException: code: 255

database migration examples rely on AMI that no longer exists

database migration tests fail with similar errors to such.

Diagnostics:
  pulumi:pulumi:Stack (database_migration-dev):
    error: update failed

  aws:rds:Cluster (db):
    error: 1 error occurred:
    	* error creating RDS cluster: InvalidParameterCombination: Cannot find version 5.7.mysql_aurora.2.03.2 for aurora-mysql
    	status code: 400, request id: 295f4c4d-3b43-427f-a3dd-bd9ef30d7c6c

Resources:
    + 3 created

typescript invalid syntax on types

node database migration CI error. appears to be caused by having an old version of typescript.

yarn run v1.22.19
$ tsc && node ./bin/index.js
Error: node_modules/@types/aws-lambda/trigger/cloudfront-request.d.ts(1,13): error TS1005: '=' expected.
Error: node_modules/@types/aws-lambda/trigger/cloudfront-request.d.ts(1,83): error TS1005: ';' expected.
Error: node_modules/@types/aws-lambda/trigger/cloudfront-request.d.ts(2,13): error TS1005: '=' expected.
Error: node_modules/@types/aws-lambda/trigger/cloudfront-request.d.ts(2,40): error TS1005: ';' expected.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.

Steps to reproduce

run CI

Expected Behavior

CI passes

Actual Behavior

doesn't pass

Output of pulumi about

No response

Additional context

No response

Contributing

Vote on this issue by adding a πŸ‘ reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.