diff --git a/aws-yaml-cue-eks/Pulumi.yaml b/aws-yaml-cue-eks/Pulumi.yaml new file mode 100644 index 000000000..b2ecff5b3 --- /dev/null +++ b/aws-yaml-cue-eks/Pulumi.yaml @@ -0,0 +1,6 @@ +name: cue +runtime: + name: yaml + options: + compiler: cue export +description: CUE Example diff --git a/aws-yaml-cue-eks/aws/eks.cue b/aws-yaml-cue-eks/aws/eks.cue new file mode 100644 index 000000000..b440979fb --- /dev/null +++ b/aws-yaml-cue-eks/aws/eks.cue @@ -0,0 +1,11 @@ +package eks + +#EksCluster: { + type: "eks:Cluster" + properties: { + instanceType: *"t2.medium" | "t3.medium" + desiredCapacity: int | *2 + minSize: int | *1 + maxSize: int | *2 + } +} diff --git a/aws-yaml-cue-eks/cue.mod/module.cue b/aws-yaml-cue-eks/cue.mod/module.cue new file mode 100644 index 000000000..f7f845cfc --- /dev/null +++ b/aws-yaml-cue-eks/cue.mod/module.cue @@ -0,0 +1 @@ +module: "examples.pulumi.com/yaml-eks" diff --git a/aws-yaml-cue-eks/main.cue b/aws-yaml-cue-eks/main.cue new file mode 100644 index 000000000..55f71a384 --- /dev/null +++ b/aws-yaml-cue-eks/main.cue @@ -0,0 +1,14 @@ +package main + +import "examples.pulumi.com/yaml-eks/aws:eks" + +resources: { + rawkode: eks.#EksCluster + stack72: eks.#EksCluster & { + properties: { + instanceType: "t2.medium" + desiredCapacity: 4 + maxSize: 8 + } + } +} diff --git a/aws-yaml-eks/Pulumi.yaml b/aws-yaml-eks/Pulumi.yaml new file mode 100644 index 000000000..aa87f9b15 --- /dev/null +++ b/aws-yaml-eks/Pulumi.yaml @@ -0,0 +1,28 @@ +name: aws-eks +runtime: yaml +description: An EKS cluster +variables: + vpcId: + Fn::Invoke: + Function: aws:ec2:getVpc + Arguments: + default: true + Return: id + subnetIds: + Fn::Invoke: + Function: aws:ec2:getSubnetIds + Arguments: + vpcId: ${vpcId} + Return: ids +resources: + cluster: + type: eks:Cluster + properties: + vpcId: ${vpcId} + subnetIds: ${subnetIds} + instanceType: "t2.medium" + desiredCapacity: 2 + minSize: 1 + maxSize: 2 +outputs: + kubeconfig: ${cluster.kubeconfig} diff --git a/aws-yaml-eks/README.md b/aws-yaml-eks/README.md new file mode 100644 index 000000000..b211f6f12 --- /dev/null +++ b/aws-yaml-eks/README.md @@ -0,0 +1,49 @@ + +# Amazon EKS Cluster + +This example deploys an EKS Kubernetes cluster inside the default AWS VPC. + +## Deploying the App + +To deploy your infrastructure, follow the below steps. + +## Prerequisites + +1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/) +1. [Configure Pulumi for AWS](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/) + +## Deploying and running the program + +1. Create a new stack: + + ``` + $ pulumi stack init dev + ``` + +1. Set the AWS region: + + ``` + $ pulumi config set aws:region us-east-2 + ``` + +1. Run `pulumi up` to preview and deploy changes: + + ``` + $ pulumi up + Previewing changes: + ... + + Performing changes: + ... + Resources: + + 28 created + + Duration: 10m0s + ``` + +1. Check the deployed kubeconfig: + + ``` + $ pulumi stack output kubeconfig + {"apiVersion":"v1","clusters":[{"cluster":{"certificate-authority-data":"LS0tLS1CRUdJTiBDR... + ``` diff --git a/aws-yaml-static-website/Pulumi.yaml b/aws-yaml-static-website/Pulumi.yaml new file mode 100644 index 000000000..00f832d11 --- /dev/null +++ b/aws-yaml-static-website/Pulumi.yaml @@ -0,0 +1,44 @@ +name: aws-native-static-website +runtime: yaml +description: A static website hosted on AWS S3 +resources: + site-bucket: + type: aws-native:s3:Bucket + properties: + websiteConfiguration: + indexDocument: index.html + index.html: + type: aws:s3:BucketObject + properties: + bucket: ${site-bucket} + source: + Fn::FileAsset: ./www/index.html + acl: public-read + contentType: text/html + favicon.png: + type: aws:s3:BucketObject + properties: + bucket: ${site-bucket} + source: + Fn::FileAsset: ./www/favicon.png + acl: public-read + contentType: image/png + bucketPolicy: + type: aws:s3:BucketPolicy + properties: + bucket: ${site-bucket} + policy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": "*", + "Action": ["s3:GetObject"], + "Resource": ["${site-bucket.arn}/*"] + } + ] + } +outputs: + bucketName: ${site-bucket.bucketName} + websiteUrl: ${site-bucket.websiteURL} diff --git a/aws-yaml-static-website/README.md b/aws-yaml-static-website/README.md new file mode 100644 index 000000000..cf88a305b --- /dev/null +++ b/aws-yaml-static-website/README.md @@ -0,0 +1,99 @@ +[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-native-ts-s3-folder/README.md) + +# Host a Static Website on Amazon S3 with the AWS Native Provider + +A static website that uses [S3's website support](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html). +For a detailed walkthrough of this example, see the tutorial [Static Website on AWS S3](https://www.pulumi.com/docs/tutorials/aws/s3-website/). + +Note: Some resources are not yet supported by the Native AWS provider, so we are using both the Native +and Classic provider in this example. The resources will be updated to use native resources as they are +available in AWS's Cloud Control API. + +## Deploying and running the program + +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + +1. Install required plugins: + + ```bash + $ pulumi plugin install resource aws 4.37.3 + $ pulumi plugin install resource aws-native 0.11.0 + ``` + +1. Create a new stack: + + ```bash + $ pulumi stack init dev + ``` + +1. Set the AWS region: + + Either using an environment variable + ```bash + $ export AWS_REGION=us-west-2 + ``` + + Or with the stack config + ```bash + $ pulumi config set aws:region us-west-2 + $ pulumi config set aws-native:region us-west-2 + ``` + +1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. + + ```bash + $ pulumi up + Previewing update (dev) + ... + + Updating (dev) + + View Live: https://app.pulumi.com/***/aws-native-ts-s3-folder/dev/updates/1 + + Type Name Status + + pulumi:pulumi:Stack aws-native-ts-s3-folder-dev created + + ├─ aws-native:s3:Bucket s3-website-bucket created + + ├─ aws:s3:BucketPolicy bucketPolicy created + + ├─ aws:s3:BucketObject index.html created + + └─ aws:s3:BucketObject favicon.png created + + Outputs: + bucketName: "***" + websiteUrl: "http://***.s3-website-us-west-2.amazonaws.com" + + Resources: + + 5 created + + Duration: *** + ``` + +1. To see the resources that were created, run `pulumi stack output`: + + ```bash + $ pulumi stack output + Current stack outputs (2): + OUTPUT VALUE + bucketName *** + websiteUrl http://***.s3-website-us-west-2.amazonaws.com + ``` + +1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI: + + ```bash + $ aws s3 ls $(pulumi stack output bucketName) + 2021-09-30 15:27:58 13731 favicon.png + 2021-09-30 15:27:58 198 index.html + ``` + +1. Open the site URL in a browser to see both the rendered HTML and the favicon: + + ```bash + $ pulumi stack output websiteUrl + ***.s3-website-us-west-2.amazonaws.com + ``` + + ![Hello S3 example](https://user-images.githubusercontent.com/274700/116912066-9384e300-abfc-11eb-8130-dbcff512a9de.png) + +1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt. diff --git a/aws-yaml-static-website/www/favicon.png b/aws-yaml-static-website/www/favicon.png new file mode 100644 index 000000000..ad4baeb6f Binary files /dev/null and b/aws-yaml-static-website/www/favicon.png differ diff --git a/aws-yaml-static-website/www/index.html b/aws-yaml-static-website/www/index.html new file mode 100644 index 000000000..80793df17 --- /dev/null +++ b/aws-yaml-static-website/www/index.html @@ -0,0 +1,15 @@ + + + + + Hello, Pulumi! + + + + +

Hello, S3!

+

Made with ❤️ with Pulumi

+

This file is served from Amazon S3.

+ + + diff --git a/azure-yaml-app-service/Pulumi.yaml b/azure-yaml-app-service/Pulumi.yaml new file mode 100644 index 000000000..a55b4d75c --- /dev/null +++ b/azure-yaml-app-service/Pulumi.yaml @@ -0,0 +1,103 @@ +name: azure-app-service +runtime: yaml +description: A static website hosted on AWS S3 +configuration: + sqlAdmin: + type: String + default: pulumi +variables: + blobAccessToken: + Fn::Invoke: + Function: azure-native:storage:listStorageAccountServiceSAS + Arguments: + accountName: ${sa.name} + protocols: https + sharedAccessStartTime: '2022-01-01' + sharedAccessExpiryTime: '2030-01-01' + resource: c + resourceGroupName: ${appservicegroup.name} + permissions: r + canonicalizedResource: /blob/${sa.name}/${container.name} + contentType: application/json + cacheControl: max-age=5 + contentDisposition: inline + contentEncoding: deflate + Return: serviceSasToken +resources: + appservicegroup: + type: azure-native:resources:ResourceGroup + sa: + type: azure-native:storage:StorageAccount + properties: + resourceGroupName: ${appservicegroup.name} + kind: 'StorageV2' + sku: { name: 'Standard_LRS' } + appserviceplan: + type: azure-native:web:AppServicePlan + properties: + resourceGroupName: ${appservicegroup.name} + kind: App + sku: + name: B1 + tier: Basic + container: + type: azure-native:storage:BlobContainer + properties: + resourceGroupName: ${appservicegroup.name} + accountName: ${sa.name} + publicAccess: None + blob: + type: azure-native:storage:Blob + properties: + resourceGroupName: ${appservicegroup.name} + accountName: ${sa.name} + containerName: ${container.name} + type: 'Block' + source: + Fn::FileArchive: ./www + appInsights: + type: azure-native:insights:Component + properties: + resourceGroupName: ${appservicegroup.name} + applicationType: web + kind: web + sqlPassword: + type: random:RandomPassword + properties: + length: 16 + special: true + sqlServer: + type: azure-native:sql:Server + properties: + resourceGroupName: ${appservicegroup.name} + administratorLogin: ${sqlAdmin} + administratorLoginPassword: ${sqlPassword.result} + version: '12.0' + db: + type: azure-native:sql:Database + properties: + resourceGroupName: ${appservicegroup.name} + serverName: ${sqlServer.name} + sku: { name: 'S0' } + + app: + type: azure-native:web:WebApp + properties: + resourceGroupName: ${appservicegroup.name} + serverFarmId: ${appserviceplan} + siteConfig: + appSettings: + - name: WEBSITE_RUN_FROM_PACKAGE + value: https://${sa.name}.blob.core.windows.net/${container.name}/${blob.name}?${blobAccessToken} + - name: APPINSIGHTS_INSTRUMENTATIONKEY + value: ${appInsights.instrumentationKey} + - name: APPLICATIONINSIGHTS_CONNECTION_STRING + value: InstrumentationKey=${appInsights.instrumentationKey} + - name: ApplicationInsightsAgent_EXTENSION_VERSION + value: ~2 + connectionStrings: + - name: db + type: SQLAzure + connectionString: Server= tcp:${sqlServer.name}.database.windows.net;initial catalog=${db.name};userID=${sqlAdmin};password=${sqlPassword.result};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true; +outputs: + endpoint: ${app.defaultHostName} diff --git a/azure-yaml-app-service/README.md b/azure-yaml-app-service/README.md new file mode 100644 index 000000000..a4d7fa0fd --- /dev/null +++ b/azure-yaml-app-service/README.md @@ -0,0 +1,89 @@ +[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/azure-cs-appservice/README.md) + +# Azure App Service with SQL Database and Application Insights + +Starting point for building web application hosted in Azure App Service. + +Provisions Azure SQL Database and Azure Application Insights to be used in combination +with App Service. + +## Deploying the App + +To deploy your infrastructure, follow the below steps. + +### Prerequisites + +1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/) + +### Steps + +1. Install required plugins: + + ```bash + $ pulumi plugin install resource azure-native 1.56.0 + $ pulumi plugin install resource random 4.3.1 + ``` + +1. Create a new stack: + + ``` + $ pulumi stack init dev + ``` + +1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step): + + ``` + $ az login + ``` + +1. Configure the location to deploy the resources to: + + ``` + $ pulumi config set azure-native:location centralus + ``` + +1. Run `pulumi up` to preview and deploy changes: + + ``` + $ pulumi up + Previewing changes: + ... + + Performing changes: + ... + info: 11 changes performed: + + 11 resources created + Update duration: 1m14.59910109s + ``` + +1. Check the deployed website endpoint: + + ``` + $ pulumi stack output Endpoint + https://azpulumi-as0ef47193.azurewebsites.net + $ curl "$(pulumi stack output endpoint)" + + + + + Hello, Pulumi! + + + + +

Hello, Azure!

+

Made with ❤️ with Pulumi

+

This file is served from Azure App Service, via Blob Storage.

+ + + + ``` + +6. From there, feel free to experiment. Simply making edits and running `pulumi up` will incrementally update your stack. + +7. Once you've finished experimenting, tear down your stack's resources by destroying and removing it: + + ```bash + $ pulumi destroy --yes + $ pulumi stack rm --yes + ``` diff --git a/azure-yaml-app-service/www/404.html b/azure-yaml-app-service/www/404.html new file mode 100644 index 000000000..ccf077d86 --- /dev/null +++ b/azure-yaml-app-service/www/404.html @@ -0,0 +1,14 @@ + + + + + Oops, 404 + + + + +

That's a 404! Still, from the Blob Storage.

+

Made with ❤️ with Pulumi

+ + + diff --git a/azure-yaml-app-service/www/favicon.png b/azure-yaml-app-service/www/favicon.png new file mode 100644 index 000000000..ad4baeb6f Binary files /dev/null and b/azure-yaml-app-service/www/favicon.png differ diff --git a/azure-yaml-app-service/www/index.html b/azure-yaml-app-service/www/index.html new file mode 100644 index 000000000..850ade127 --- /dev/null +++ b/azure-yaml-app-service/www/index.html @@ -0,0 +1,15 @@ + + + + + Hello, Pulumi! + + + + +

Hello, Azure!

+

Made with ❤️ with Pulumi

+

This file is served from Azure App Service, via Blob Storage.

+ + + diff --git a/azure-yaml-container-apps/Pulumi.yaml b/azure-yaml-container-apps/Pulumi.yaml new file mode 100644 index 000000000..d101bff3c --- /dev/null +++ b/azure-yaml-container-apps/Pulumi.yaml @@ -0,0 +1,93 @@ +name: azure-container-apps +runtime: yaml +description: Azure Container Apps example +configuration: + sqlAdmin: + type: String + default: pulumi +variables: + sharedKey: + Fn::Invoke: + Function: azure-native:operationalinsights:getSharedKeys + Arguments: + resourceGroupName: ${resourceGroup.name} + workspaceName: ${workspace.name} + Return: primarySharedKey + adminUsername: + Fn::Invoke: + Function: azure-native:containerregistry:listRegistryCredentials + Arguments: + resourceGroupName: ${resourceGroup.name} + registryName: ${registry.name} + Return: username + adminPasswords: + Fn::Invoke: + Function: azure-native:containerregistry:listRegistryCredentials + Arguments: + resourceGroupName: ${resourceGroup.name} + registryName: ${registry.name} + Return: passwords +resources: + resourceGroup: + type: azure-native:resources:ResourceGroup + workspace: + type: azure-native:operationalinsights:Workspace + properties: + resourceGroupName: ${resourceGroup.name} + sku: + name: "PerGB2018" + retentionInDays: 30 + kubeEnv: + type: azure-native:web:KubeEnvironment + properties: + resourceGroupName: ${resourceGroup.name} + environmentType: Managed + appLogsConfiguration: + destination: "log-analytics" + logAnalyticsConfiguration: + customerId: ${workspace.customerId} + sharedKey: ${sharedKey} + registry: + type: azure-native:containerregistry:Registry + properties: + resourceGroupName: ${resourceGroup.name} + sku: + name: "Basic" + adminUserEnabled: true + provider: + type: pulumi:providers:docker + properties: + registryAuth: + - address: ${registry.loginServer} + username: ${adminUsername} + password: ${adminPasswords[0].value} + myImage: + type: docker:RegistryImage + properties: + name: ${registry.loginServer}/node-app:v1.0.0 + build: + context: ${pulumi.cwd}/node-app + options: + provider: ${provider} + containerapp: + type: azure-native:web:ContainerApp + properties: + resourceGroupName: ${resourceGroup.name} + kubeEnvironmentId: ${kubeEnv} + configuration: + ingress: + external: true + targetPort: 80 + registries: + - server: ${registry.loginServer} + username: ${adminUsername} + passwordSecretRef: "pwd" + secrets: + - name: "pwd" + value: ${adminPasswords[0].value} + template: + containers: + - name: "myapp" + image: ${myImage.name} +outputs: + endpoint: https://${containerapp.configuration.ingress.fqdn} diff --git a/azure-yaml-container-apps/README.md b/azure-yaml-container-apps/README.md new file mode 100644 index 000000000..1bfe0b26e --- /dev/null +++ b/azure-yaml-container-apps/README.md @@ -0,0 +1,49 @@ +# Azure Container Apps + +Starting point for building web application hosted in Azure Container Apps. + +## Running the App + +1. Create a new stack: + + ``` + $ pulumi stack init dev + ``` + +1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step): + + ``` + $ az login + ``` + +1. Set the Azure region location to use: + + ``` + $ pulumi config set azure-native:location westus2 + ``` + +1. Run `pulumi up` to preview and deploy changes: + + ``` + $ pulumi up + Previewing changes: + ... + + Performing changes: + ... + Resources: + + 7 created + + Duration: 4m18s + ``` + +1. Check the deployed endpoint: + + ``` + $ curl "$(pulumi stack output url)" + + +

Your custom docker image is running in Azure Container Apps!

+ + + ``` diff --git a/azure-yaml-container-apps/node-app/.dockerignore b/azure-yaml-container-apps/node-app/.dockerignore new file mode 100644 index 000000000..93f136199 --- /dev/null +++ b/azure-yaml-container-apps/node-app/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/azure-yaml-container-apps/node-app/Dockerfile b/azure-yaml-container-apps/node-app/Dockerfile new file mode 100644 index 000000000..53bbea666 --- /dev/null +++ b/azure-yaml-container-apps/node-app/Dockerfile @@ -0,0 +1,6 @@ +FROM node:8.9.3-alpine +RUN mkdir -p /usr/src/app +COPY ./app/* /usr/src/app/ +WORKDIR /usr/src/app +RUN npm install +CMD node /usr/src/app/index.js diff --git a/azure-yaml-container-apps/node-app/app/index.html b/azure-yaml-container-apps/node-app/app/index.html new file mode 100644 index 000000000..1ca449104 --- /dev/null +++ b/azure-yaml-container-apps/node-app/app/index.html @@ -0,0 +1,6 @@ + + + +

Your custom docker image is running in Azure Container Apps!

+ + diff --git a/azure-yaml-container-apps/node-app/app/index.js b/azure-yaml-container-apps/node-app/app/index.js new file mode 100644 index 000000000..7d87fba91 --- /dev/null +++ b/azure-yaml-container-apps/node-app/app/index.js @@ -0,0 +1,13 @@ +const express = require('express'); +const morgan = require('morgan'); + +const app = express(); +app.use(morgan('combined')); + +app.get('/', (req, res) => { + res.sendFile(__dirname + '/index.html') +}); + +var listener = app.listen(process.env.PORT || 80, function() { + console.log('listening on port ' + listener.address().port); +}); diff --git a/azure-yaml-cue-static-web-app/Pulumi.yaml b/azure-yaml-cue-static-web-app/Pulumi.yaml new file mode 100644 index 000000000..b2ecff5b3 --- /dev/null +++ b/azure-yaml-cue-static-web-app/Pulumi.yaml @@ -0,0 +1,6 @@ +name: cue +runtime: + name: yaml + options: + compiler: cue export +description: CUE Example diff --git a/azure-yaml-cue-static-web-app/app.cue b/azure-yaml-cue-static-web-app/app.cue new file mode 100644 index 000000000..6592f8c0e --- /dev/null +++ b/azure-yaml-cue-static-web-app/app.cue @@ -0,0 +1,68 @@ +package main + +resources: { + (#StaticWebApp & { + _name: "rawkode" + }).resources + + (#StaticWebApp & { + _name: "stack72" + _documents: { + root: "website" + index: "index.html" + } + }).resources +} + +#StaticWebApp: { + _name: string + _documents: { + root: string | *"website" + index: string | *"index.html" + error404: string | *"404.html" + } + + resources: { + "\(_name)-group": { + type: "azure-native:resources:ResourceGroup" + properties: { + location: "WestUs" + } + } + + "\(_name)-storage": { + type: "azure-native:storage:StorageAccount" + properties: { + resourceGroupName: "${\(_name)-group.name}" + kind: "StorageV2" + sku: { + name: "Standard_LRS" + } + } + } + + "\(_name)-website": { + type: "azure-native:storage:StorageAccountStaticWebsite" + properties: { + resourceGroupName: "${\(_name)-group.name}" + accountName: "${\(_name)-storage.name}" + indexDocument: "\(_documents.index)" + error404Document: "\(_documents.error404)" + } + } + + "\(_name)-\(_documents.index)": { + type: "azure-native:storage:Blob" + properties: { + resourceGroupName: "${\(_name)-group.name}" + accountName: "${\(_name)-storage.name}" + containerName: "${\(_name)-website.containerName}" + contentType: "text/html" + type: "Block" + source: { + "Fn::FileAsset": "./\(_documents.root)/\(_documents.index)" + } + } + } + } +} diff --git a/azure-yaml-cue-static-web-app/website/404.html b/azure-yaml-cue-static-web-app/website/404.html new file mode 100644 index 000000000..ccf077d86 --- /dev/null +++ b/azure-yaml-cue-static-web-app/website/404.html @@ -0,0 +1,14 @@ + + + + + Oops, 404 + + + + +

That's a 404! Still, from the Blob Storage.

+

Made with ❤️ with Pulumi

+ + + diff --git a/azure-yaml-cue-static-web-app/website/favicon.png b/azure-yaml-cue-static-web-app/website/favicon.png new file mode 100644 index 000000000..ad4baeb6f Binary files /dev/null and b/azure-yaml-cue-static-web-app/website/favicon.png differ diff --git a/azure-yaml-cue-static-web-app/website/index.html b/azure-yaml-cue-static-web-app/website/index.html new file mode 100644 index 000000000..ef3fefaef --- /dev/null +++ b/azure-yaml-cue-static-web-app/website/index.html @@ -0,0 +1,15 @@ + + + + + Hello, Pulumi! + + + + +

Hello, Azure!

+

Made with ❤️ with Pulumi

+

This file is served from Azure Blob Storage.

+ + + diff --git a/azure-yaml-static-website/Pulumi.yaml b/azure-yaml-static-website/Pulumi.yaml new file mode 100644 index 000000000..dbf6d663c --- /dev/null +++ b/azure-yaml-static-website/Pulumi.yaml @@ -0,0 +1,51 @@ +name: azure-static-website +runtime: yaml +description: A static website hosted on AWS S3 +resources: + staticsitegroup: + type: azure-native:resources:ResourceGroup + storageaccount: + type: azure-native:storage:StorageAccount + properties: + resourceGroupName: ${staticsitegroup.name} + kind: "StorageV2" + sku: { name: "Standard_LRS" } + staticwebsite: + type: azure-native:storage:StorageAccountStaticWebsite + properties: + resourceGroupName: ${staticsitegroup.name} + accountName: ${storageaccount.name} + indexDocument: index.html + error404Document: 404.html + index.html: + type: azure-native:storage:Blob + properties: + resourceGroupName: ${staticsitegroup.name} + accountName: ${storageaccount.name} + containerName: ${staticwebsite.containerName} + contentType: text/html + type: 'Block' + source: + Fn::FileAsset: ./www/index.html + favicon.png: + type: azure-native:storage:Blob + properties: + resourceGroupName: ${staticsitegroup.name} + accountName: ${storageaccount.name} + containerName: ${staticwebsite.containerName} + contentType: image/png + type: 'Block' + source: + Fn::FileAsset: ./www/favicon.png + 404.html: + type: azure-native:storage:Blob + properties: + resourceGroupName: ${staticsitegroup.name} + accountName: ${storageaccount.name} + containerName: ${staticwebsite.containerName} + contentType: text/html + type: 'Block' + source: + Fn::FileAsset: ./www/404.html +outputs: + endpoint: ${storageaccount.primaryEndpoints.web} diff --git a/azure-yaml-static-website/README.md b/azure-yaml-static-website/README.md new file mode 100644 index 000000000..39211a4b0 --- /dev/null +++ b/azure-yaml-static-website/README.md @@ -0,0 +1,70 @@ +[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/azure-cs-static-website/README.md) + +# Static Website Using Azure Blob Storage and CDN + +This example configures [Static website hosting in Azure Storage](https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website). + +In addition to the Storage itself, a CDN is configured to serve files from the Blob container origin. This may be useful if you need to serve files via HTTPS from a custom domain (not shown in the example). + +## Running the App + +1. Install required plugins: + + ```bash + $ pulumi plugin install resource azure-native 1.56.0 + ``` + +1. Create a new stack: + + ``` + $ pulumi stack init dev + ``` + +1. Login to Azure CLI (you will be prompted to do this during deployment if you forget this step): + + ``` + $ az login + ``` + +1. Set the Azure region location to use: + + ``` + $ pulumi config set azure-native:location westus + ``` + +1. Run `pulumi up` to preview and deploy changes: + + ``` + $ pulumi up + Previewing changes: + ... + + Performing changes: + ... + Resources: + + 9 created + Duration: 2m52s + ``` + +1. Check the deployed website endpoint: + + ``` + $ pulumi stack output endpoint + https://websitesbc90978a1.z20.web.core.windows.net/ + $ curl "$(pulumi stack output endpoint)" + + + + + Hello, Pulumi! + + + + +

Hello, Azure!

+

Made with ❤️ with Pulumi

+

This file is served from Azure Blob Storage.

+ + + + ``` diff --git a/azure-yaml-static-website/www/404.html b/azure-yaml-static-website/www/404.html new file mode 100644 index 000000000..ccf077d86 --- /dev/null +++ b/azure-yaml-static-website/www/404.html @@ -0,0 +1,14 @@ + + + + + Oops, 404 + + + + +

That's a 404! Still, from the Blob Storage.

+

Made with ❤️ with Pulumi

+ + + diff --git a/azure-yaml-static-website/www/favicon.png b/azure-yaml-static-website/www/favicon.png new file mode 100644 index 000000000..ad4baeb6f Binary files /dev/null and b/azure-yaml-static-website/www/favicon.png differ diff --git a/azure-yaml-static-website/www/index.html b/azure-yaml-static-website/www/index.html new file mode 100644 index 000000000..ef3fefaef --- /dev/null +++ b/azure-yaml-static-website/www/index.html @@ -0,0 +1,15 @@ + + + + + Hello, Pulumi! + + + + +

Hello, Azure!

+

Made with ❤️ with Pulumi

+

This file is served from Azure Blob Storage.

+ + + diff --git a/kubernetes-yaml/Pulumi.yaml b/kubernetes-yaml/Pulumi.yaml new file mode 100644 index 000000000..7964b1bc0 --- /dev/null +++ b/kubernetes-yaml/Pulumi.yaml @@ -0,0 +1,54 @@ +name: simple-kubernetes +runtime: yaml +configuration: + hostname: + default: example.com + type: String +resources: + nginx-demo: # namespace name generated based on resource name + type: kubernetes:core/v1:Namespace + app: + type: kubernetes:apps/v1:Deployment + properties: + metadata: + namespace: ${nginx-demo.metadata.name} + spec: + selector: + matchLabels: + app.kubernetes.io/name: nginx-demo + replicas: 1 + template: + metadata: + labels: + app.kubernetes.io/name: nginx-demo + spec: + containers: [{ name: app, image: "nginx:1.15-alpine" }] + service: + type: kubernetes:core/v1:Service + properties: + metadata: + namespace: ${nginx-demo.metadata.name} + labels: + app.kubernetes.io/name: nginx-demo + spec: + type: ClusterIP + ports: [{ port: 80, targetPort: 80, protocol: "TCP" }] + selector: + app.kubernetes.io/name: nginx-demo + ingress: + type: kubernetes:networking.k8s.io/v1:Ingress + properties: + metadata: + namespace: ${nginx-demo.metadata.name} + spec: + rules: + - host: ${hostname} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: ${service.metadata.name} + port: + number: 80 diff --git a/random-yaml-cue/Pulumi.yaml b/random-yaml-cue/Pulumi.yaml new file mode 100644 index 000000000..b2ecff5b3 --- /dev/null +++ b/random-yaml-cue/Pulumi.yaml @@ -0,0 +1,6 @@ +name: cue +runtime: + name: yaml + options: + compiler: cue export +description: CUE Example diff --git a/random-yaml-cue/infra.cue b/random-yaml-cue/infra.cue new file mode 100644 index 000000000..b515f0221 --- /dev/null +++ b/random-yaml-cue/infra.cue @@ -0,0 +1,14 @@ +package pulumi + +resources: + randomPassword: { + type: "random:RandomPassword" + properties: { + length: 16 + special: true + overrideSpecial: "_%@" + } + } + +outputs: + password: "${randomPassword.result}" diff --git a/random-yaml/Pulumi.yaml b/random-yaml/Pulumi.yaml new file mode 100644 index 000000000..3f8e87ac0 --- /dev/null +++ b/random-yaml/Pulumi.yaml @@ -0,0 +1,11 @@ +name: random +runtime: yaml +resources: + randomPassword: + type: random:RandomPassword + properties: + length: 16 + special: true + overrideSpecial: "_%@" +outputs: + password: ${randomPassword.result} diff --git a/random-yaml/README.md b/random-yaml/README.md new file mode 100644 index 000000000..d67e42ca2 --- /dev/null +++ b/random-yaml/README.md @@ -0,0 +1,49 @@ +# Generate secure random passwords to use in deployments + +The [Random package](https://www.pulumi.com/registry/packages/random/api-docs/) provides resources with outputs that are random IDs, passwords, or other data. + +## Deploying and running the program + +1. Create a new stack: + + ```bash + $ pulumi stack init dev + ``` + +1. Install required plugins: + + ```bash + $ pulumi plugin install resource random 4.3.1 + ``` + +1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. + + ```bash + $ pulumi up + Previewing update (dev) + ... + + Updating (dev) + + View Live: https://app.pulumi.com/.../random/dev/updates/1 + + Type Name Status + + pulumi:pulumi:Stack random-dev created + + └─ random:index:RandomPassword randomPassword created + + Outputs: + password: "[secret]" + + Resources: + + 2 created + ``` + +1. To see the resources that were created, run `pulumi stack output`: + + ```bash + $ pulumi stack output --show-secrets + Current stack outputs (1): + OUTPUT VALUE + password ... + ``` diff --git a/webserver-yaml-json/Main.json b/webserver-yaml-json/Main.json new file mode 100644 index 000000000..5387fbfd0 --- /dev/null +++ b/webserver-yaml-json/Main.json @@ -0,0 +1,61 @@ +{ + "Configuration": { + "InstanceType": { + "type": "String", + "default": "t3.micro" + } + }, + "Resources": { + "WebSecGrp": { + "Type": "aws:ec2:SecurityGroup", + "Properties": { + "ingress": [ + { + "protocol": "tcp", + "fromPort": 80, + "toPort": 80, + "cidrBlocks": ["0.0.0.0/0"] + } + ] + }, + "Options": { + "Version": "4.37.1" + } + }, + "WebServer": { + "Type": "aws:ec2:Instance", + "Properties": { + "instanceType": "${InstanceType}", + "ami": { + "Fn::Invoke": { + "Function": "aws:getAmi", + "Arguments": { + "filters": [ + { "name": "name", "values": ["amzn-ami-hvm-*-x86_64-ebs"] } + ], + "owners": ["137112412989"], + "mostRecent": true + }, + "Return": "id" + } + }, + "userData": { + "Fn::Join": [ + "\n", + [ + "#!/bin/bash", + "echo 'Hello, World from ${WebSecGrp.arn}!' > index.html", + "nohup python -m SimpleHTTPServer 80 &" + ] + ] + }, + "vpcSecurityGroupIds": ["${WebSecGrp.id}"] + } + } + }, + "Outputs": { + "InstanceId": "${WebServer.id}", + "PublicIp": "${WebServer.publicIp}", + "PublicHostName": "${WebServer.publicDns}" + } +} diff --git a/webserver-yaml-json/Pulumi.yaml b/webserver-yaml-json/Pulumi.yaml new file mode 100755 index 000000000..f86777619 --- /dev/null +++ b/webserver-yaml-json/Pulumi.yaml @@ -0,0 +1,3 @@ +name: webserver-json +runtime: yaml +description: Basic example of an AWS web server accessible over HTTP diff --git a/webserver-yaml/Pulumi.yaml b/webserver-yaml/Pulumi.yaml new file mode 100755 index 000000000..a0002793c --- /dev/null +++ b/webserver-yaml/Pulumi.yaml @@ -0,0 +1,50 @@ +name: webserver +runtime: yaml +description: Basic example of an AWS web server accessible over HTTP +configuration: + InstanceType: + type: String + default: t3.micro +variables: + ec2ami: + Fn::Invoke: + Function: aws:getAmi + Arguments: + filters: + - name: name + values: ["amzn-ami-hvm-*-x86_64-ebs"] + owners: ["137112412989"] + mostRecent: true + Return: id +resources: + WebSecGrp: + type: aws:ec2:SecurityGroup + properties: + ingress: + - protocol: tcp + fromPort: 80 + toPort: 80 + cidrBlocks: ["0.0.0.0/0"] + WebServer: + type: aws:ec2:Instance + properties: + instanceType: ${InstanceType} + ami: ${ec2ami} + userData: |- + #!/bin/bash + echo 'Hello, World from ${WebSecGrp.arn}!' > index.html + nohup python -m SimpleHTTPServer 80 & + vpcSecurityGroupIds: + - ${WebSecGrp} + UsEast2Provider: + type: pulumi:providers:aws + properties: + region: us-east-2 + MyBucket: + type: aws:s3:Bucket + options: + provider: ${UsEast2Provider} +outputs: + InstanceId: ${WebServer.id} + PublicIp: ${WebServer.publicIp} + PublicHostName: ${WebServer.publicDns}