Pulumi Examples - Infrastructure as Code

October 31, 2022 ยท View on GitHub

AZURE PYTHON AZURE TYPESCRIPT AZURE GO AZURE CLASSIC TYPESCRIPT

AWS PYTHON AWS TYPESCRIPT

GOOGLE-NATIVE PYTHON

This repository contains Pulumi examples for AWS, Azure, and Google Cloud Platform. The examples are in TypeScript, python, and go.

Examples are in different languages & different clouds

ts = typescript, py = python, go = go

Prerequisite - How to Get Started with Pulumi - skip if you have already done this

PREREQ

CLOUDSTEPSCOMMENTS
AWS1. Getting Started with AWSStart with 1 cloud only. Then when you need to, configure the next cloud.
AWS2. Configure your AWS accountStart with 1 cloud only. Then when you need to, configure the next cloud.
AZURE1. Getting Started with AZUREStart with 1 cloud only. Then when you need to, configure the next cloud.
AZURE2. Configure your Azure accountStart with 1 cloud only. Then when you need to, configure the next cloud.
GOOGLE1.Getting Started with GOOGLEStart with 1 cloud only. Then when you need to, configure the next cloud.
GOOGLE2.Configure your Google accountStart with 1 cloud only. Then when you need to, configure the next cloud.

[![PULUMI AccessToken]How to set up your ACCESS TOKEN** - Only need to do this once, no need to do it for each cloud.

  1. Navigate to Profile Settings by selecting your avatar, then Settings.
  2. Click on Access Tokens on the left side.
  3. Create a new AccessToken. Copy the AccessToken to your clipboard to use in the next step. Enter your AccessToken on the next step after
  4. On your cli: pulumi login

AWS

ExampleDescriptionCloud & Language
aws-classic-ts-vpc-with-ecs-fargate-pyvpc built-in TypeScript - independent from ecs, ecs uses vpc via stackreferencesAWS PYTHON AWS TYPESCRIPT
aws-classic-ts-sshkeyssh keyAWS TYPESCRIPT
aws-classic-ts-vpc-crosswalkvpc built-in TypeScript via crosswalkAWS TYPESCRIPT
aws-classic-ts-acm-awsguardtls private key, aws self signed certificate and acm created. Running awsguard. Calling pulumi-policy-awsAWS TYPESCRIPT
aws-classic-ts-launchtemplateec2 via launchtemplate. also has vpc, securitygroup, & ssh keypair. Addd tags.ts for tags. Calls thenAWS TYPESCRIPT
aws-classic-ts-vpc-ecs-autoscaling-ltvpc, ecs, autoscaling groups, and launchtemplate in TypeScript. This creates a new vpcAWS TYPESCRIPT
aws-ts-existingvpc-ecs-autoscaling-ltexisting vpc, ecs, autoscaling groups, and launchtemplate in TypeScript. Calls then creates a new vpcAWS TYPESCRIPT
aws-classic-ts-ecs-awsxuses an existing vpc, creates ecs via awsx, loadbalancer via aws. no targetgroup or targetlistener created. next stack is aws-classic-ts-get-ecsAWS TYPESCRIPT
aws-classic-ts-get-ecsuses an existing vpc, calls the existing ecs created via aws-classic-ts-ecs-awsxAWS TYPESCRIPT
aws-classic-ts-ekseks cluster with namespaceAWS TYPESCRIPT
aws-classic-ts-eks-spot-mgeks cluster with spot managednode instance with vpc via awsxAWS TYPESCRIPT
aws-classic-ts-eks-awsx-spoteks cluster with no managed nodes, spot nodegroup, and interface nginx with provider with vpc via awsxAWS TYPESCRIPT
aws-classic-ts-lakeformationaws lakeformation permissionsAWS TYPESCRIPT
aws-classic-ts-eks-different-awsprofileaws eks cluster with awsx vpc with different aws config profile, not using defaultAWS TYPESCRIPT
aws-classic-ts-eks-nodetaintaws eks cluster with awsx vpc with no managednodegroup, one fixed nodegroup, and on spot nodegroup. The spot nodegroup has taints.AWS TYPESCRIPT
aws-classic-ts-eks-node-alltaintsaws eks cluster with awsx vpc with no managednodegroup, fixed & spot nodegroup both have taints.AWS TYPESCRIPT
aws-classic-ts-ebs-volume-snapshotaws ebs volume with multiple snapshots. then used, for loop used, and protectAWS TYPESCRIPT
aws-classic-ts-ec2-instance-with-ebs-volumeaws vpc with awsx package, ec2 instance with encrypted storage and 2 ebs volumes added that are encrypted. Call then on getAmi and on the subnet ID to use. Also call interpolateAWS TYPESCRIPT
aws-classic-ts-vpc-quickstartaws vpc with aws quickstart vpcAWS TYPESCRIPT
aws-classic-ts-eks-vpc-sg-default-rulesaws vpc with EKS with no security group rule passed in aws quickstart vpcAWS TYPESCRIPT
aws-classic-ts-vpc-peeringconnectionoption2 vpcs in SAME regions connecting them via vpcpeeringconnectionAWS TYPESCRIPT
aws-classic-ts-vpc-peeringconnectionoption2 vpcs in different regions via providers and then connecting them via vpcpeeringconnection cross accountAWS TYPESCRIPT
aws-classic-ts-vpc-natgatway-strategyawsx multilang vpc with single nat gateway strategyAWS TYPESCRIPT
aws-classic-ts-vpc-get-zones-awsxawsx multilang vpc with single nat gateway strategy, availability zones, public and private subnets, NO APPLYAWS TYPESCRIPT
aws-classic-ts-securitygroup-vs-securitygrouprulesmultilang vpc with single nat gateway strategy, availability zones, public and private subnets, securitygroup vs securitygroup rules. Also call self on securitygroupAWS TYPESCRIPT
aws-classic-ts-vpc-rds-postgresmultilang vpc with single nat gateway strategy, availability zones, public and private subnets, rds, & programtically creating secrets.AWS TYPESCRIPT
aws-py-ecs-fargateDeploys your own ECS Fargate cluster with tags and uses the vpc via stackreferencesAWS PYTHON
aws-classic-py-s3-staticwebsiteDeploy you own static site in s3AWS PYTHON
aws-classic-py-apigateway-lambda-serverlessAPI Gateway with lambda. swagger and openapi apigateways. Using the triggers option. added multiple pathsAWS PYTHON
aws-classic-py-dynamodbdynamodb tableAWS PYTHON
aws-classic-py-vpccreates aws vpc, subnet, igw, nat-gateway(1-3), & route tables all in python. no awsx packageAWS PYTHON
aws-classic-py-eks-spot-mgeks cluster with spot managednode instance. Creates own vpc based on aws-classic-py-vpc that is in vpc.pyAWS PYTHON
aws-classic-py-aws-load-balancer-controller-helm-releaseeks cluster with spot managednode instance. Creates own vpc based on aws-classic-py-vpc that is in vpc.py. Installs aws-load-balancer-controller as helm release. Also pass in the cluster as a providerAWS PYTHON
aws-classic-py-eksaws eks cluster with namespaceAWS PYTHON
aws-classic-py-eks-spot-nodegroupsaws eks cluster with no managednode group and fixed and spot nodegroupsAWS PYTHON
aws-classic-py-beanstalkaws beanstalk applicationAWS PYTHON
aws-classic-py-get-amiaws get amiAWS PYTHON
aws-classic-py-get-regionsaws get regionsAWS PYTHON
aws-classic-py-vpc-quickstartaws vpc with aws quickstart vpcAWS PYTHON
aws-classic-py-vpc-msk-kafka-clientawsx vpc with kinesis firehose, individual az via apply, msk kafka clusterAWS PYTHON
aws-classic-py-vpc-msk-kafka-client-part2awsx vpc keypair, ami, ec2 instance as a clientAWS PYTHON
aws-classic-py-multiple-ec2-ebsmultilanguage awsx vpc keypair, ami, multiple ec2s with ebs block, with applyAWS PYTHON
aws-classic-py-vpc-awsx-natgateway-strategymultilanguage awsx vpc vpc, natgateway single zone strategy, igw, public and private subnetsAWS PYTHON
aws-classic-py-vpc-awsx-natgateway-strategyawsx vpc multilang vpc with single nat gateway strategy, availability zones, public and private subnets, NO APPLYAWS PYTHON
aws-classic-py-securitygroup-vs-securitygrouprulesawsx vpc multilang vpc with single nat gateway strategy, availability zones, public and private subnets, securitygroups vs securitygroup rulesAWS PYTHON

Azure

ExampleDescriptionCloud & Language
azure-classic-py-insightsazure classic resource group, workspace & insights. azure native resource group & workspace mixed with azure classic insightsAZURE PYTHON
azure-py-insightsazure native resource group, workspace & azure classic insights. azure native resource group & workspace mixed with azure classic insightsAZURE PYTHON
azure-py-vnetazure virtual network with 2 subnets.AZURE PYTHON
azure-py-databricksazure databricks. Also retrieving subscription ID and using Output.concatAZURE PYTHON
azure-py-subscriptionid-from-resourcegroupazure resource group creating and retrieving subscriptionIdAZURE PYTHON
azure-py-rg-storageaccountsazure resource group and storage account with secret outputsAZURE PYTHON
azure-py-aksazure resource group, azuread service principal pinned to 4.3.0, aks, and outputs with secret outputsAZURE PYTHON
azure-py-aks-diagnosticsettingazure resource group, azuread service principal pinned to 4.3.0, aks, and diagnostic settings and outputs with secret outputsAZURE PYTHON
azure-py-redisazure resource group, storage account, redis cache, apply, call the listrediskeys functionAZURE PYTHON
azure-py-keyvault-appserviceplan-webserviceazure resource group, appserviceplan, webapp,keyvault, tenant ID, subscription ID, object ID, replaced VaultPropertiesResponseArgs with VaultPropertiesArgsAZURE PYTHON
azure-py-storage-account-networkrulesetresponseargsazure resource group, storage account, replaced NetworkRuleSetResponseArgs with NetworkRuleSetArgsAZURE PYTHON
azure-ts-sqlserver-loganalyticsSQL Server database with SQL auditing at the database level sent to log analytics in TypeScriptAZURE typescript
azure-ts-keyvaultcreate and destroy azure keyvault in TypeScriptAZURE typescript
azure-ts-consumption-budgetazure consumption budget and switching languages from German to EnglishAZURE typescript
azure-classic-ts-datalakegen2azure native resource group, storage account, azure classic datalakegen2 path and datalakegen2 filesystemAZURE typescript AZURE CLASSIC TYPESCRIPT
azure-ts-iac-workshop-lab1azure workshop lab 1, creates resourceg group, storage account, and blob container. Code works independently, does not require workshopAZURE typescript
azure-ts-serverless-http-triggerazure workshop lab 2, azure serverless http trigger function workshop code. Code works independently, does not require workshopAZURE typescript
azure-ts-resourcegroup-fixnameazure resource group fixed namesAZURE typescript
azure-ts-subscriptionid-from-resourcegroupazure resource group creating and retrieving subscriptionIdAZURE typescript
azure-ts-jenkinsjenkins deployed on azure function with docker image in tsAZURE typescript
azure-ts-sqlserver-servervulnerabilityassessmentazure sql server with vulnerability assessment requires that Azure Defender for SQL Server turned on at subscription level. Due to Azure Consistency issues, we have to uncomment out code and the run pulumi up a couple of minutes after the sql database has been createdAZURE typescript
azure-ts-sqlserverazure sql server with firewall rule that toggles Allow Azure services from No to YesAZURE typescript
azure-ts-synapse-workspaceazure datalakestore with synapse sqlpoolAZURE typescript
azure-ts-synapse-bigdatapoolazure synapse workspace with synapse bigdatapoolAZURE typescript
azure-ts-serverless-www-HTMLazure static site with StorageAccountStaticWebsiteAZURE typescript
azure-ts-managedinstanceazure resource group, vnet, subnet1/2 with delegation created. Code for managedinstance is there, do NOT use it when standing up intital stack. Main reason, is that managedinstance takes 3+ hours to stand up. Create managedinstance in azure portal and then import it.AZURE typescript
azure-ts-datafactoryazure datafactory with identity set to SystemAssignedAZURE typescript
azure-ts-aks-managed-profileazure aks with aadprofile input enableAzureRBAC toggledAZURE typescript
azure-classic-ts-datafactoryazure classic datafactory with identity set to SystemAssignedAZURE CLASSIC TYPESCRIPT
azure-go-aks-diagnosticsettingazure resource group, azuread service principal pinned to 4.3.0, aks, and diagnostic settings and outputs with secret outputsAZURE GO
azure-go-resourcegroupazure resource group and storage accountAZURE GO
azure-go-subscriptionid-from-resourcegroupazure resource group creating and retrieving subscriptionIdAZURE GO
azure-go-sqlserver-loganalyticssql server database with sql auditing at the database level sent to log analytics in go. Busted due to typoAZURE GO
azure-go-sqlserver-servervulnerabilityassessmentazure sql server with vulnerability assessment requires that Azure Defender for SQL Server turned on at subscription level. Due to Azure Consistency issues, we have to uncomment out code and the run pulumi up a couple of minutes after the sql database has been created.AZURE GO

Google

ExampleDescriptionCloud & Language
google-native-py-network-postgres-functiongoogle cloud native - storage bucket & vpc & postgresGOOGLE PYTHON
google-native-py-bigquerydatatransfergoogle cloud native - storage bucket, google classic - bigquery and service account and data transfer configGOOGLE PYTHON

DataDog

ExampleDescriptionCloud & Language
datadog-py-monitorjsondatadog monitorjsonDATADOG PYTHON

Pulumi

ExampleDescriptionCloud & Language
pulumi-ts-map-string-stringpulumi with no cloud. output Map<string,string> is empty while console.log shows the valueDATADOG PYTHON

Workshops

ExampleDescriptionCloud & Language
azure-workshop-tsazure serverless http trigger function workshop in TypeScriptAZURE typescript

PULUMI GITHUB ACTIONS

Pulumi GitHub Actions Setup (Optional)

We have setup Pulumi GitHub Actions.

  1. Located in .github/workflows

  2. Pull WorkFlow Files for Python with comments by GitHub actions

  3. Pull WorkFlow Files for TypeScript with comments by GitHub actions

  4. Pull WorkFlow Files for Go with comments by GitHub actions

  5. SuperLinter setup

    • super-linter setup
    • superlinter.yml - .github/workflows/superlinter.yml
    • slim image
    • VALIDATE_PYTHON_BLACK turned OFF
    • VALIDATE_PYTHON_FLAKE8 turned OFF
    • VALIDATE_PYTHON_ISORT turned OFF
    • VALIDATE_TYPESCRIPT_STANDARD turned OFF
  6. AWS SSO login in for GitHub Actions

  7. Removed from githubactions pipeline due to service principal issues even though preview and up work via cli

    • azure-ts-keyvault, azure-classic-ts-datalakegen2, azure-classic-ts-datafactory
    • azure-py-insights, azure-classic-py-insights, azure-py-aks-diagnosticsetting

License

license