diff --git a/aws-ts-airflow/index.ts b/aws-ts-airflow/index.ts index b8e6d6a6c..b19858d5a 100644 --- a/aws-ts-airflow/index.ts +++ b/aws-ts-airflow/index.ts @@ -1,15 +1,17 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; +import * as pulumi from "@pulumi/pulumi"; -let config = new pulumi.Config("airflow"); +const config = new pulumi.Config("airflow"); const dbPassword = config.require("dbPassword"); -let vpc = awsx.ec2.Vpc.getDefault(); +const vpc = awsx.ec2.Vpc.getDefault(); // Create a basic cluster and autoscaling group -let cluster = new awsx.ecs.Cluster("airflow", { vpc }); -let autoScalingGroup = cluster.createAutoScalingGroup("airflow", { +const cluster = new awsx.ecs.Cluster("airflow", { vpc }); +const autoScalingGroup = cluster.createAutoScalingGroup("airflow", { subnetIds: vpc.publicSubnetIds, templateParameters: { minSize: 20, @@ -19,13 +21,13 @@ let autoScalingGroup = cluster.createAutoScalingGroup("airflow", { }, }); -let securityGroupIds = cluster.securityGroups.map(g => g.id); +const securityGroupIds = cluster.securityGroups.map(g => g.id); -let dbSubnets = new aws.rds.SubnetGroup("dbsubnets", { +const dbSubnets = new aws.rds.SubnetGroup("dbsubnets", { subnetIds: vpc.publicSubnetIds, }); -let db = new aws.rds.Instance("postgresdb", { +const db = new aws.rds.Instance("postgresdb", { engine: "postgres", instanceClass: "db.t2.micro", @@ -41,11 +43,11 @@ let db = new aws.rds.Instance("postgresdb", { skipFinalSnapshot: true, }); -let cacheSubnets = new aws.elasticache.SubnetGroup("cachesubnets", { +const cacheSubnets = new aws.elasticache.SubnetGroup("cachesubnets", { subnetIds: vpc.publicSubnetIds, }); -let cacheCluster = new aws.elasticache.Cluster("cachecluster", { +const cacheCluster = new aws.elasticache.Cluster("cachecluster", { clusterId: `cache-${pulumi.getStack()}`.substr(0, 20), engine: "redis", @@ -56,21 +58,21 @@ let cacheCluster = new aws.elasticache.Cluster("cachecluster", { securityGroupIds: securityGroupIds, }); -let hosts = pulumi.all([db.endpoint.apply(e => e.split(":")[0]), cacheCluster.cacheNodes[0].address]); -let environment = hosts.apply(([postgresHost, redisHost]) => [ +const hosts = pulumi.all([db.endpoint.apply(e => e.split(":")[0]), cacheCluster.cacheNodes[0].address]); +const environment = hosts.apply(([postgresHost, redisHost]) => [ { name: "POSTGRES_HOST", value: postgresHost }, { name: "POSTGRES_PASSWORD", value: dbPassword }, { name: "REDIS_HOST", value: redisHost }, - { name: "EXECUTOR", value: "Celery" } + { name: "EXECUTOR", value: "Celery" }, ]); -let airflowControllerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflowcontroller", { +const airflowControllerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflowcontroller", { external: true, port: 8080, protocol: "HTTP", }); -let airflowController = new awsx.ecs.EC2Service("airflowcontroller", { +const airflowController = new awsx.ecs.EC2Service("airflowcontroller", { cluster, desiredCount: 1, taskDefinitionArgs: { @@ -93,13 +95,13 @@ let airflowController = new awsx.ecs.EC2Service("airflowcontroller", { }, }); -let airflowerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflower", { +const airflowerListener = new awsx.elasticloadbalancingv2.ApplicationListener("airflower", { port: 5555, external: true, - protocol: "HTTP" + protocol: "HTTP", }); -let airflower = new awsx.ecs.EC2Service("airflower", { +const airflower = new awsx.ecs.EC2Service("airflower", { cluster, taskDefinitionArgs: { containers: { @@ -116,7 +118,7 @@ let airflower = new awsx.ecs.EC2Service("airflower", { }, }); -let airflowWorkers = new awsx.ecs.EC2Service("airflowworkers", { +const airflowWorkers = new awsx.ecs.EC2Service("airflowworkers", { cluster, desiredCount: 3, taskDefinitionArgs: { diff --git a/aws-ts-apigateway-auth0/index.ts b/aws-ts-apigateway-auth0/index.ts index c6279aac1..15e2764d4 100644 --- a/aws-ts-apigateway-auth0/index.ts +++ b/aws-ts-apigateway-auth0/index.ts @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. import * as awsx from "@pulumi/awsx"; -import * as pulumi from '@pulumi/pulumi'; +import * as pulumi from "@pulumi/pulumi"; -import * as jwksClient from 'jwks-rsa'; -import * as jwt from 'jsonwebtoken'; -import * as util from 'util'; +import * as jwt from "jsonwebtoken"; +import * as jwksClient from "jwks-rsa"; +import * as util from "util"; const config = new pulumi.Config(); const jwksUri = config.require("jwksUri"); @@ -66,7 +66,7 @@ export const url = api.url; // Extract and return the Bearer Token from the Lambda event parameters function getToken(event: awsx.apigateway.AuthorizerEvent): string { - if (!event.type || event.type !== 'TOKEN') { + if (!event.type || event.type !== "TOKEN") { throw new Error('Expected "event.type" parameter to have value "TOKEN"'); } @@ -89,33 +89,33 @@ async function authenticate(event: awsx.apigateway.AuthorizerEvent): PromisetoBeDetermined).sub !== undefined; -} \ No newline at end of file +} diff --git a/aws-ts-apigateway/index.ts b/aws-ts-apigateway/index.ts index 569a9a36b..20429bd98 100644 --- a/aws-ts-apigateway/index.ts +++ b/aws-ts-apigateway/index.ts @@ -1,8 +1,10 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; // Create a mapping from 'route' to a count -let counterTable = new aws.dynamodb.Table("counterTable", { +const counterTable = new aws.dynamodb.Table("counterTable", { attributes: [{ name: "id", type: "S", @@ -13,12 +15,12 @@ let counterTable = new aws.dynamodb.Table("counterTable", { }); // Create an API endpoint -let endpoint = new awsx.apigateway.API("hello-world", { +const endpoint = new awsx.apigateway.API("hello-world", { routes: [{ path: "/{route+}", method: "GET", eventHandler: async (event) => { - let route = event.pathParameters!["route"]; + const route = event.pathParameters!["route"]; console.log(`Getting count for '${route}'`); const client = new aws.sdk.DynamoDB.DocumentClient(); diff --git a/aws-ts-appsync/iam.ts b/aws-ts-appsync/iam.ts index 700c256e8..c22c9d771 100644 --- a/aws-ts-appsync/iam.ts +++ b/aws-ts-appsync/iam.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; +import * as pulumi from "@pulumi/pulumi"; export function createIamRole(name: string, table: aws.dynamodb.Table) { const role = new aws.iam.Role(`${name}-role`, { @@ -25,7 +27,7 @@ export function createIamRole(name: string, table: aws.dynamodb.Table) { })).json, }); - new aws.iam.RolePolicyAttachment(`${name}-rpa`, { + const attachment = new aws.iam.RolePolicyAttachment(`${name}-rpa`, { role: role, policyArn: policy.arn, }); diff --git a/aws-ts-appsync/index.ts b/aws-ts-appsync/index.ts index d8d86128b..47e72b2e3 100644 --- a/aws-ts-appsync/index.ts +++ b/aws-ts-appsync/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import { createIamRole } from "./iam"; @@ -14,7 +16,7 @@ const table = new aws.dynamodb.Table("tenants", { const role = createIamRole("iam", table); // GraphQL Schema -const schema = +const schema = `type Query { getTenantById(id: ID!): Tenant } @@ -54,7 +56,7 @@ const dataSource = new aws.appsync.DataSource("tenants-ds", { }); // A resolver for the [getTenantById] query -new aws.appsync.Resolver("get-resolver", { +const getResolver = new aws.appsync.Resolver("get-resolver", { apiId: api.id, dataSource: dataSource.name, type: "Query", @@ -66,11 +68,11 @@ new aws.appsync.Resolver("get-resolver", { "id": $util.dynamodb.toDynamoDBJson($ctx.args.id), } }`, - responseTemplate: `$util.toJson($ctx.result)` + responseTemplate: `$util.toJson($ctx.result)`, }); // A resolver for the [addTenant] mutation -new aws.appsync.Resolver("add-resolver", { +const addResolver = new aws.appsync.Resolver("add-resolver", { apiId: api.id, dataSource: dataSource.name, type: "Mutation", @@ -85,7 +87,7 @@ new aws.appsync.Resolver("add-resolver", { "name": $util.dynamodb.toDynamoDBJson($ctx.args.name) } }`, - responseTemplate: `$util.toJson($ctx.result)` + responseTemplate: `$util.toJson($ctx.result)`, }); export const endpoint = api.uris["GRAPHQL"]; @@ -95,7 +97,7 @@ export const key = apiKey.key; * * An example query: * - + query GetTenant { getTenantById(id: "123") { id @@ -105,8 +107,8 @@ export const key = apiKey.key; * * An example mutation: - * - + * + mutation AddTenant { addTenant(id: "123", name: "First Corp") { id diff --git a/aws-ts-assume-role/assume-role/index.ts b/aws-ts-assume-role/assume-role/index.ts index 201b22ee5..94aa1fcf2 100644 --- a/aws-ts-assume-role/assume-role/index.ts +++ b/aws-ts-assume-role/assume-role/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; diff --git a/aws-ts-assume-role/create-role/index.ts b/aws-ts-assume-role/create-role/index.ts index b81f042d8..a83b4375f 100644 --- a/aws-ts-assume-role/create-role/index.ts +++ b/aws-ts-assume-role/create-role/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; diff --git a/aws-ts-containers/index.ts b/aws-ts-containers/index.ts index 40711a6b6..88fff28bf 100644 --- a/aws-ts-containers/index.ts +++ b/aws-ts-containers/index.ts @@ -1,14 +1,16 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as awsx from "@pulumi/awsx"; +import * as pulumi from "@pulumi/pulumi"; // Create an elastic network listener to listen for requests and route them to the container. // See https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html // for more details. -let listener = new awsx.elasticloadbalancingv2.NetworkListener("nginx", { port: 80 }); +const listener = new awsx.elasticloadbalancingv2.NetworkListener("nginx", { port: 80 }); // Define the service to run. We pass in the listener to hook up the network load balancer // to the containers the service will launch. -let service = new awsx.ecs.FargateService("nginx", { +const service = new awsx.ecs.FargateService("nginx", { desiredCount: 2, taskDefinitionArgs: { containers: { diff --git a/aws-ts-eks-hello-world/index.ts b/aws-ts-eks-hello-world/index.ts index 0b8d93848..453dc7429 100644 --- a/aws-ts-eks-hello-world/index.ts +++ b/aws-ts-eks-hello-world/index.ts @@ -1,4 +1,5 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; @@ -19,7 +20,7 @@ const cluster = new eks.Cluster(name, { }); // Export the clusters' kubeconfig. -export const kubeconfig = cluster.kubeconfig +export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes Namespace const ns = new k8s.core.v1.Namespace(name, {}, { provider: cluster.provider }); @@ -47,16 +48,16 @@ const deployment = new k8s.apps.v1.Deployment(name, { name: name, image: "nginx:latest", - ports: [{ name: "http", containerPort: 80 }] - } + ports: [{ name: "http", containerPort: 80 }], + }, ], - } - } + }, + }, }, }, { provider: cluster.provider, - } + }, ); // Export the Deployment name @@ -77,9 +78,9 @@ const service = new k8s.core.v1.Service(name, }, { provider: cluster.provider, - } + }, ); // Export the Service name and public LoadBalancer Endpoint export const serviceName = service.metadata.name; -export const serviceHostname = service.status.apply(s => s.loadBalancer.ingress[0].hostname) +export const serviceHostname = service.status.apply(s => s.loadBalancer.ingress[0].hostname); diff --git a/aws-ts-eks-migrate-nodegroups/echoserver.ts b/aws-ts-eks-migrate-nodegroups/echoserver.ts index bfccc16da..bf2dd1ada 100644 --- a/aws-ts-eks-migrate-nodegroups/echoserver.ts +++ b/aws-ts-eks-migrate-nodegroups/echoserver.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; diff --git a/aws-ts-eks-migrate-nodegroups/iam.ts b/aws-ts-eks-migrate-nodegroups/iam.ts index 4d9f1d309..b535742e6 100644 --- a/aws-ts-eks-migrate-nodegroups/iam.ts +++ b/aws-ts-eks-migrate-nodegroups/iam.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; import * as iam from "./iam"; diff --git a/aws-ts-eks-migrate-nodegroups/index.ts b/aws-ts-eks-migrate-nodegroups/index.ts index 8ad51de68..b95e20dd1 100644 --- a/aws-ts-eks-migrate-nodegroups/index.ts +++ b/aws-ts-eks-migrate-nodegroups/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; diff --git a/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr-rbac.ts b/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr-rbac.ts index 1078df440..ec08ede55 100644 --- a/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr-rbac.ts +++ b/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr-rbac.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; diff --git a/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr.ts b/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr.ts index 775bd4794..d5f13746a 100644 --- a/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr.ts +++ b/aws-ts-eks-migrate-nodegroups/nginx-ing-cntlr.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; import * as input from "@pulumi/kubernetes/types/input"; import * as pulumi from "@pulumi/pulumi"; diff --git a/aws-ts-eks-migrate-nodegroups/nginx.ts b/aws-ts-eks-migrate-nodegroups/nginx.ts index 6918dd87a..20dbe6687 100644 --- a/aws-ts-eks-migrate-nodegroups/nginx.ts +++ b/aws-ts-eks-migrate-nodegroups/nginx.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as input from "@pulumi/kubernetes/types/input"; diff --git a/aws-ts-eks-migrate-nodegroups/utils.ts b/aws-ts-eks-migrate-nodegroups/utils.ts index 184dc00cc..70d963183 100644 --- a/aws-ts-eks-migrate-nodegroups/utils.ts +++ b/aws-ts-eks-migrate-nodegroups/utils.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as eks from "@pulumi/eks"; import * as pulumi from "@pulumi/pulumi"; diff --git a/aws-ts-eks/index.ts b/aws-ts-eks/index.ts index d74913e83..2ae1bf5d5 100644 --- a/aws-ts-eks/index.ts +++ b/aws-ts-eks/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as awsx from "@pulumi/awsx"; import * as eks from "@pulumi/eks"; diff --git a/aws-ts-hello-fargate/index.ts b/aws-ts-hello-fargate/index.ts index 56e97a7d6..55eba126c 100644 --- a/aws-ts-hello-fargate/index.ts +++ b/aws-ts-hello-fargate/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as awsx from "@pulumi/awsx"; // Step 1: Create an ECS Fargate cluster. diff --git a/aws-ts-pulumi-webhooks/index.ts b/aws-ts-pulumi-webhooks/index.ts index e73844052..1eadba74d 100644 --- a/aws-ts-pulumi-webhooks/index.ts +++ b/aws-ts-pulumi-webhooks/index.ts @@ -1,11 +1,10 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as awsx from "@pulumi/awsx"; - -import * as crypto from "crypto"; +import * as pulumi from "@pulumi/pulumi"; import * as slack from "@slack/client"; +import * as crypto from "crypto"; import { formatSlackMessage } from "./util"; @@ -54,7 +53,7 @@ const webhookHandler = new awsx.apigateway.API("pulumi-webhook-handler", { method: "GET", eventHandler: async () => ({ statusCode: 200, - body: "🍹 Pulumi Webhook Responder🍹\n" + body: "🍹 Pulumi Webhook Responder🍹\n", }), }, { path: "/", @@ -78,7 +77,7 @@ const webhookHandler = new awsx.apigateway.API("pulumi-webhook-handler", { channel: stackConfig.slackChannel, text: fallbackText, as_user: true, - } + }; // Format the Slack message based on the kind of webhook received. const formattedMessageArgs = formatSlackMessage(webhookKind, parsedPayload, messageArgs); diff --git a/aws-ts-pulumi-webhooks/util.ts b/aws-ts-pulumi-webhooks/util.ts index afaa06ae3..c2869f97b 100644 --- a/aws-ts-pulumi-webhooks/util.ts +++ b/aws-ts-pulumi-webhooks/util.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import { ChatPostMessageArguments } from "@slack/client"; // Return a formatted copy of the Slack message object, based on the kind of Pulumi webhook received. @@ -15,9 +17,9 @@ export function formatSlackMessage(kind: string, payload: object, messageArgs: C case "stack_preview": case "stack_update": return formatUpdate(kind, payload, cloned); + default: + return cloned; } - - return cloned; } function formatStack(payload: any, args: ChatPostMessageArguments): ChatPostMessageArguments { @@ -40,7 +42,7 @@ function formatStack(payload: any, args: ChatPostMessageArguments): ChatPostMess ], }, ]; - return args + return args; } function formatTeam(payload: any, args: ChatPostMessageArguments): ChatPostMessageArguments { @@ -133,8 +135,9 @@ function resultColor(result: string): string { return "#36a64f"; case "failed": return "#e01563"; + default: + return "#e9a820"; } - return "#e9a820"; } function resultEmoji(result: string): string { @@ -143,8 +146,9 @@ function resultEmoji(result: string): string { return ":tropical_drink:"; case "failed": return ":rotating_light:"; + default: + return ""; } - return ""; } function titleCase(s: string): string { diff --git a/aws-ts-resources/index.ts b/aws-ts-resources/index.ts index da164e781..9d33a35be 100644 --- a/aws-ts-resources/index.ts +++ b/aws-ts-resources/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; +import * as pulumi from "@pulumi/pulumi"; // Athena // const databaseBucket = new aws.s3.Bucket("mydatabasebucket"); @@ -30,14 +32,14 @@ const dashboard = new aws.cloudwatch.Dashboard("mydashboard", { "AWS/EC2", "CPUUtilization", "InstanceId", - "i-012345" - ] + "i-012345", + ], ], period: 300, stat: "Average", region: "us-east-1", - title: "EC2 Instance CPU" - } + title: "EC2 Instance CPU", + }, }, { type: "text", @@ -46,11 +48,11 @@ const dashboard = new aws.cloudwatch.Dashboard("mydashboard", { width: 3, height: 3, properties: { - markdown: "Hello world" - } - } - ] - }) + markdown: "Hello world", + }, + }, + ], + }), }); const loginsTopic = new aws.sns.Topic("myloginstopic"); @@ -58,16 +60,16 @@ const loginsTopic = new aws.sns.Topic("myloginstopic"); const eventRule = new aws.cloudwatch.EventRule("myeventrule", { eventPattern: JSON.stringify({ "detail-type": [ - "AWS Console Sign In via CloudTrail" - ] - }) + "AWS Console Sign In via CloudTrail", + ], + }), }); const eventTarget = new aws.cloudwatch.EventTarget("myeventtarget", { rule: eventRule.name, targetId: "SendToSNS", - arn: loginsTopic.arn -}) + arn: loginsTopic.arn, +}); const logGroup = new aws.cloudwatch.LogGroup("myloggroup"); @@ -77,12 +79,12 @@ const logMetricFilter = new aws.cloudwatch.LogMetricFilter("mylogmetricfilter", metricTransformation: { name: "EventCount", namespace: "YourNamespace", - value: "1" - } + value: "1", + }, }); const logStream = new aws.cloudwatch.LogStream("mylogstream", { - logGroupName: logGroup.name + logGroupName: logGroup.name, }); const metricAlarm = new aws.cloudwatch.MetricAlarm("mymetricalarm", { @@ -93,7 +95,7 @@ const metricAlarm = new aws.cloudwatch.MetricAlarm("mymetricalarm", { period: 120, statistic: "Average", threshold: 80, - alarmDescription: "This metric monitors ec2 cpu utilization" + alarmDescription: "This metric monitors ec2 cpu utilization", }); // DynamoDB @@ -116,8 +118,8 @@ const securityGroup = new aws.ec2.SecurityGroup("mysecuritygroup", { }); const vpc = new aws.ec2.Vpc("myvpc", { - cidrBlock: "10.0.0.0/16" -}) + cidrBlock: "10.0.0.0/16", +}); const internetGateway = new aws.ec2.InternetGateway("myinternetgateway", { vpcId: vpc.id, @@ -158,10 +160,10 @@ const repositoryPolicy = new aws.ecr.RepositoryPolicy("myrepositorypolicy", { "ecr:DeleteRepository", "ecr:BatchDeleteImage", "ecr:SetRepositoryPolicy", - "ecr:DeleteRepositoryPolicy" - ] - }] - }) + "ecr:DeleteRepositoryPolicy", + ], + }], + }), }); const lifecyclePolicy = new aws.ecr.LifecyclePolicy("mylifecyclepolicy", { @@ -174,13 +176,13 @@ const lifecyclePolicy = new aws.ecr.LifecyclePolicy("mylifecyclepolicy", { tagStatus: "untagged", countType: "sinceImagePushed", countUnit: "days", - countNumber: 14 + countNumber: 14, }, action: { - type: "expire" - } - }] - }) + type: "expire", + }, + }], + }), }); // ECS @@ -208,7 +210,7 @@ const policy = new aws.iam.Policy("mypolicy", { Version: "2012-10-17", Statement: [{ Action: [ - "ec2:Describe*" + "ec2:Describe*", ], Effect: "Allow", Resource: "*", @@ -218,7 +220,7 @@ const policy = new aws.iam.Policy("mypolicy", { const rolePolicyAttachment = new aws.iam.RolePolicyAttachment("myrolepolicyattachment", { role: role, - policyArn: policy.arn + policyArn: policy.arn, }); const user = new aws.iam.User("myuser"); @@ -229,12 +231,12 @@ const group = new aws.iam.Group("mygroup"); // users: [user], // groups: [group], // roles: [role], -// policyArn: policy.arn +// policyArn: policy.arn, // }); // Kinesis const stream = new aws.kinesis.Stream("mystream", { - shardCount: 1 + shardCount: 1, }); // S3 @@ -283,5 +285,5 @@ const topic = new aws.sns.Topic("mytopic"); const topicSubscription = new aws.sns.TopicSubscription("mytopicsubscription", { topic: topic, protocol: "sqs", - endpoint: queue.arn + endpoint: queue.arn, }); diff --git a/aws-ts-ruby-on-rails/config.ts b/aws-ts-ruby-on-rails/config.ts index a7eeffe74..82a9965e0 100644 --- a/aws-ts-ruby-on-rails/config.ts +++ b/aws-ts-ruby-on-rails/config.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; @@ -8,7 +10,7 @@ export const dbName = config.get("dbName") || "MyDatabase"; if (!/[a-zA-Z][a-zA-Z0-9]*/.test(dbName)) { throw new Error("dbName must begin with a letter and contain only alphanumeric characters"); } else if (dbName.length < 1 || dbName.length > 64) { - throw new Error("dbName must between 1-64 characters, inclusively") + throw new Error("dbName must between 1-64 characters, inclusively"); } // dbUser is the username for MySQL database access. diff --git a/aws-ts-ruby-on-rails/index.ts b/aws-ts-ruby-on-rails/index.ts index 837f9f666..179cd73f3 100644 --- a/aws-ts-ruby-on-rails/index.ts +++ b/aws-ts-ruby-on-rails/index.ts @@ -1,7 +1,9 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; -import * as config from "./config"; +import * as pulumi from "@pulumi/pulumi"; import { createUserData, renderConfigFile } from "pcloudinit"; +import * as config from "./config"; const webSg = new aws.ec2.SecurityGroup("webServerSecurityGroup", { description: "Enable HTTP and SSH access", @@ -21,8 +23,8 @@ const amiId = aws.getAmi({ }, { name: "virtualization-type", - values: ["hvm"] - } + values: ["hvm"], + }, ], mostRecent: true, owners: ["137112412989"], diff --git a/aws-ts-s3-lambda-copyzip/index.ts b/aws-ts-s3-lambda-copyzip/index.ts index fcd866f61..b2c82b2bc 100644 --- a/aws-ts-s3-lambda-copyzip/index.ts +++ b/aws-ts-s3-lambda-copyzip/index.ts @@ -1,16 +1,18 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; +import * as pulumi from "@pulumi/pulumi"; // Create a bucket each for TPS reports and their archived zips. const tpsReports = new aws.s3.Bucket("tpsReports"); -const tpsZips = new aws.s3.Bucket("tpsZips") +const tpsZips = new aws.s3.Bucket("tpsZips"); // Anytime a new TPS Report is uploaded, archive it in a zipfile. tpsReports.onObjectCreated("zipTpsReports", async (e) => { - const AdmZip = require("adm-zip"); + const admZip = require("adm-zip"); const s3 = new aws.sdk.S3(); for (const rec of e.Records || []) { - const zip = new AdmZip(); + const zip = new admZip(); const [ buck, key ] = [ rec.s3.bucket.name, rec.s3.object.key ]; console.log(`Zipping ${buck}/${key} into ${tpsZips.bucket.get()}/${key}.zip`); const data = await s3.getObject({ Bucket: buck, Key: key }).promise(); diff --git a/aws-ts-serverless-raw/index.ts b/aws-ts-serverless-raw/index.ts index c96b3ef3e..7416b18b5 100644 --- a/aws-ts-serverless-raw/index.ts +++ b/aws-ts-serverless-raw/index.ts @@ -1,20 +1,20 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; +import * as pulumi from "@pulumi/pulumi"; // The location of the built dotnet2.1 application to deploy -let dotNetApplicationPublishFolder = "./app/bin/Debug/netcoreapp2.1/publish"; -let dotNetApplicationEntryPoint = "app::app.Functions::GetAsync"; +const dotNetApplicationPublishFolder = "./app/bin/Debug/netcoreapp2.1/publish"; +const dotNetApplicationEntryPoint = "app::app.Functions::GetAsync"; // The stage name to use for the API Gateway URL -let stageName = "api"; +const stageName = "api"; /////////////////// // DynamoDB Table /////////////////// // A DynamoDB table with a single primary key -let counterTable = new aws.dynamodb.Table("counterTable", { +const counterTable = new aws.dynamodb.Table("counterTable", { attributes: [ { name: "Id", type: "S" }, ], @@ -49,7 +49,7 @@ const policy = new aws.iam.RolePolicy("mylambda-policy", { }); // Create a Lambda function, using code from the `./app` folder. -let lambda = new aws.lambda.Function("mylambda", { +const lambda = new aws.lambda.Function("mylambda", { runtime: aws.lambda.DotnetCore2d1Runtime, code: new pulumi.asset.AssetArchive({ ".": new pulumi.asset.FileArchive(dotNetApplicationPublishFolder), @@ -59,7 +59,7 @@ let lambda = new aws.lambda.Function("mylambda", { role: role.arn, environment: { variables: { - "COUNTER_TABLE": counterTable.name + "COUNTER_TABLE": counterTable.name, }, }, }, { dependsOn: [policy] }); @@ -70,7 +70,7 @@ let lambda = new aws.lambda.Function("mylambda", { // Create the Swagger spec for a proxy which forwards all HTTP requests through to the Lambda function. function swaggerSpec(lambdaArn: string): string { - let swaggerSpec = { + const swaggerSpec = { swagger: "2.0", info: { title: "api", version: "1.0" }, paths: { @@ -82,7 +82,7 @@ function swaggerSpec(lambdaArn: string): string { // Create a single Swagger spec route handler for a Lambda function. function swaggerRouteHandler(lambdaArn: string) { - let region = aws.config.requireRegion(); + const region = aws.config.requireRegion(); return { "x-amazon-apigateway-any-method": { "x-amazon-apigateway-integration": { @@ -96,26 +96,26 @@ function swaggerRouteHandler(lambdaArn: string) { } // Create the API Gateway Rest API, using a swagger spec. -let restApi = new aws.apigateway.RestApi("api", { +const restApi = new aws.apigateway.RestApi("api", { body: lambda.arn.apply(lambdaArn => swaggerSpec(lambdaArn)), }); // Create a deployment of the Rest API. -let deployment = new aws.apigateway.Deployment("api-deployment", { +const deployment = new aws.apigateway.Deployment("api-deployment", { restApi: restApi, // Note: Set to empty to avoid creating an implicit stage, we'll create it explicitly below instead. stageName: "", }); // Create a stage, which is an addressable instance of the Rest API. Set it to point at the latest deployment. -let stage = new aws.apigateway.Stage("api-stage", { +const stage = new aws.apigateway.Stage("api-stage", { restApi: restApi, deployment: deployment, stageName: stageName, }); // Give permissions from API Gateway to invoke the Lambda -let invokePermission = new aws.lambda.Permission("api-lambda-permission", { +const invokePermission = new aws.lambda.Permission("api-lambda-permission", { action: "lambda:invokeFunction", function: lambda, principal: "apigateway.amazonaws.com", diff --git a/aws-ts-slackbot/index.ts b/aws-ts-slackbot/index.ts index 827e75af6..4e701b4ef 100644 --- a/aws-ts-slackbot/index.ts +++ b/aws-ts-slackbot/index.ts @@ -1,6 +1,8 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; +import * as pulumi from "@pulumi/pulumi"; import * as qs from "qs"; import * as superagent from "superagent"; @@ -20,7 +22,7 @@ const subscriptionsTable = new aws.dynamodb.Table("subscriptions", { type: "S", }], hashKey: "id", - billingMode: "PAY_PER_REQUEST" + billingMode: "PAY_PER_REQUEST", }); // Slack has strict requirements on how fast you must be when responding to their messages. In order @@ -36,7 +38,7 @@ interface SlackRequest { } interface UrlVerificationRequest extends SlackRequest { - type: "url_verification", + type: "url_verification"; challenge: string; } @@ -73,7 +75,7 @@ const endpoint = new awsx.apigateway.API("mentionbot", { } if (!verificationToken) { - throw new Error("mentionbot:verificationToken was not provided") + throw new Error("mentionbot:verificationToken was not provided"); } if (!event.isBase64Encoded || event.body == null) { @@ -97,7 +99,7 @@ const endpoint = new awsx.apigateway.API("mentionbot", { if (eventRequest.token !== verificationToken) { console.log("Error: Invalid verification token"); - return { statusCode: 401, body: "Invalid verification token" } + return { statusCode: 401, body: "Invalid verification token" }; } await onEventCallback(eventRequest); @@ -198,7 +200,7 @@ async function onMessageEventCallback(request: EventCallbackRequest) { } const permaLink = await getPermalink(event.channel, event.event_ts); - const text = `New mention at: ${permaLink}` + const text = `New mention at: ${permaLink}`; await sendChannelMessage(getResult.Item.channel, text); } @@ -206,19 +208,19 @@ async function onMessageEventCallback(request: EventCallbackRequest) { async function sendChannelMessage(channel: string, text: string) { const message = { token: slackToken, channel, text }; - await superagent.get(`https://slack.com/api/chat.postMessage?${qs.stringify(message)}`) + await superagent.get(`https://slack.com/api/chat.postMessage?${qs.stringify(message)}`); } -async function getPermalink(channel: string, message_ts: string) { - const message = { token: slackToken, channel, message_ts }; - const result = await superagent.get(`https://slack.com/api/chat.getPermalink?${qs.stringify(message)}`) +async function getPermalink(channel: string, timestamp: string) { + const message = { token: slackToken, channel, message_ts: timestamp }; + const result = await superagent.get(`https://slack.com/api/chat.getPermalink?${qs.stringify(message)}`); return JSON.parse(result.text).permalink; } async function onAppMentionEventCallback(request: EventCallbackRequest) { // Got an app_mention to @mentionbot. const event = request.event; - var promise = event.text.toLowerCase().indexOf("unsubscribe") >= 0 + const promise = event.text.toLowerCase().indexOf("unsubscribe") >= 0 ? unsubscribeFromMentions(event) : subscribeToMentions(event); diff --git a/aws-ts-stackreference/company/index.ts b/aws-ts-stackreference/company/index.ts index 25d85e09e..2bdc0a425 100644 --- a/aws-ts-stackreference/company/index.ts +++ b/aws-ts-stackreference/company/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; /** diff --git a/aws-ts-stackreference/department/index.ts b/aws-ts-stackreference/department/index.ts index eb8ca75b9..e161b2724 100644 --- a/aws-ts-stackreference/department/index.ts +++ b/aws-ts-stackreference/department/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; /** diff --git a/aws-ts-stackreference/team/index.ts b/aws-ts-stackreference/team/index.ts index 90b65bdbd..651e85641 100644 --- a/aws-ts-stackreference/team/index.ts +++ b/aws-ts-stackreference/team/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; diff --git a/aws-ts-static-website/index.ts b/aws-ts-static-website/index.ts index adfd02726..49b7636b7 100644 --- a/aws-ts-static-website/index.ts +++ b/aws-ts-static-website/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; +import * as pulumi from "@pulumi/pulumi"; import * as fs from "fs"; import * as mime from "mime"; @@ -28,7 +30,7 @@ const contentBucket = new aws.s3.Bucket("contentBucket", website: { indexDocument: "index.html", errorDocument: "404.html", - } + }, }); // crawlDirectory recursive crawls the provided directory, applying the provided function diff --git a/aws-ts-stepfunctions/index.ts b/aws-ts-stepfunctions/index.ts index 50019e830..735a7d0f4 100644 --- a/aws-ts-stepfunctions/index.ts +++ b/aws-ts-stepfunctions/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as pulumi from "@pulumi/pulumi"; @@ -16,7 +18,7 @@ const lambdaRolePolicy = new aws.iam.RolePolicy("lambdaRolePolicy", { Action: [ "logs:CreateLogGroup", "logs:CreateLogStream", - "logs:PutLogEvents" + "logs:PutLogEvents", ], Resource: "arn:aws:logs:*:*:*", }], @@ -46,7 +48,7 @@ const helloFunction = new aws.serverless.Function( { role: lambdaRole }, (event, context, callback) => { callback(null, "Hello"); - } + }, ); const worldFunction = new aws.serverless.Function( @@ -54,7 +56,7 @@ const worldFunction = new aws.serverless.Function( {role: lambdaRole}, (event, context, callback) => { callback(null, `${event} World!`); - } + }, ); const stateMachine = new aws.sfn.StateMachine("stateMachine", { @@ -68,16 +70,16 @@ const stateMachine = new aws.sfn.StateMachine("stateMachine", { "Hello": { "Type": "Task", "Resource": helloArn, - "Next": "World" + "Next": "World", }, "World": { "Type": "Task", "Resource": worldArn, - "End": true - } - } + "End": true, + }, + }, }); - }) + }), }); -exports.stateMachineArn = stateMachine.id; +export const stateMachineArn = stateMachine.id; diff --git a/aws-ts-thumbnailer/index.ts b/aws-ts-thumbnailer/index.ts index 33cea8b7c..bb0fe1a8c 100644 --- a/aws-ts-thumbnailer/index.ts +++ b/aws-ts-thumbnailer/index.ts @@ -1,4 +1,4 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; @@ -38,8 +38,8 @@ bucket.onObjectCreated("onNewVideo", new aws.lambda.CallbackFunction { +const handler = eventRule.onEvent("on-timer-event", async() => { console.log("Timer fired."); - let twitterClient = require("twitter"); - var client = new twitterClient({ + const twitterClient = require("twitter"); + const client = new twitterClient({ consumer_key: consumerKey, consumer_secret: consumerSecret, access_token_key: accessTokenKey, @@ -37,16 +39,16 @@ let handler = eventRule.onEvent("on-timer-event", async() => { }); const tweets = await new Promise((resolve, reject) => { - client.get('search/tweets', {q: twitterQuery, count: 100}, function(error: any, tweets: any, response: any) { + client.get("search/tweets", {q: twitterQuery, count: 100}, function(error: any, tweets: any, response: any) { if (error) { return reject(error); } - let statuses = tweets.statuses; + const statuses = tweets.statuses; console.log(`Got ${statuses.length} statuses.`); - let results = statuses.map((s: any) => { - let user = s.user.screen_name; + const results = statuses.map((s: any) => { + const user = s.user.screen_name; return JSON.stringify({ created_at: s.created_at, @@ -67,10 +69,10 @@ let handler = eventRule.onEvent("on-timer-event", async() => { console.log(`Got ${tweets.length} tweets from Twitter for query ${twitterQuery}`); - let filename = `${outputFolder}/${Date.now()}`; - let contents = Buffer.from(tweets.join("\n"), "utf8"); + const filename = `${outputFolder}/${Date.now()}`; + const contents = Buffer.from(tweets.join("\n"), "utf8"); - let s3 = new aws.sdk.S3(); + const s3 = new aws.sdk.S3(); await s3.putObject({ Bucket: bucket.id.get(), Key: filename, @@ -79,8 +81,8 @@ let handler = eventRule.onEvent("on-timer-event", async() => { }); // athena setup -let athena = new aws.athena.Database("tweets_database_1", - { name: "tweets_database_1", bucket: bucket.id, forceDestroy: true } +const athena = new aws.athena.Database("tweets_database_1", + { name: "tweets_database_1", bucket: bucket.id, forceDestroy: true }, ); // Sadly, there isn't support for Athena tables in Terraform. @@ -101,24 +103,23 @@ function createTableQuery(bucket: string) { LOCATION 's3://${bucket}/${outputFolder}/';`; } -let topUsersQuery = +const topUsersQuery = `select distinct user, followers, text, url from tweets where isRetweet = false and followers > 1000 order by followers desc`; -let createTableAthenaQuery = new aws.athena.NamedQuery( +const createTableAthenaQuery = new aws.athena.NamedQuery( "createTable", { database: athena.id, query: bucketName.apply(createTableQuery)}); -let topUsersAthenaQuery = new aws.athena.NamedQuery("topUsers", { database: athena.id, query: topUsersQuery}); +const topUsersAthenaQuery = new aws.athena.NamedQuery("topUsers", { database: athena.id, query: topUsersQuery}); function getQueryUri(queryId: string) { - let config = new pulumi.Config("aws"); - let region = config.require("region"); + const config = new pulumi.Config("aws"); + const region = config.require("region"); return `https://${region}.console.aws.amazon.com/athena/home?force#query/saved/${queryId}`; } -exports.bucketName = bucketName -exports.athenaDatabase = athena.id; -exports.topUsersQueryUri = topUsersAthenaQuery.id.apply(getQueryUri); -exports.createTableQueryUri = createTableAthenaQuery.id.apply(getQueryUri); +export const athenaDatabase = athena.id; +export const topUsersQueryUri = topUsersAthenaQuery.id.apply(getQueryUri); +export const createTableQueryUri = createTableAthenaQuery.id.apply(getQueryUri); diff --git a/aws-ts-url-shortener-cache-http/cache.ts b/aws-ts-url-shortener-cache-http/cache.ts index 549ce1d14..d16db5902 100644 --- a/aws-ts-url-shortener-cache-http/cache.ts +++ b/aws-ts-url-shortener-cache-http/cache.ts @@ -1,8 +1,7 @@ -// Copyright 2016-2017, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; -import * as aws from "@pulumi/aws"; import * as awsx from "@pulumi/awsx"; +import * as pulumi from "@pulumi/pulumi"; import * as config from "./config"; // A simple cache abstraction that wraps Redis. @@ -11,8 +10,8 @@ export class Cache { private readonly endpoint: pulumi.Output; constructor(name: string, memory: number = 128) { - let pw = config.redisPassword; - let listener = new awsx.elasticloadbalancingv2.NetworkListener(name, { port: 6379 }); + const pw = config.redisPassword; + const listener = new awsx.elasticloadbalancingv2.NetworkListener(name, { port: 6379 }); this.redis = new awsx.ecs.FargateService(name, { taskDefinitionArgs: { containers: { @@ -30,10 +29,10 @@ export class Cache { } public get(key: string): Promise { - let ep = this.endpoint.get(); + const ep = this.endpoint.get(); console.log(`Getting key '${key}' on Redis@${ep.hostname}:${ep.port}`); - let client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); + const client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); return new Promise((resolve, reject) => { client.get(key, (err: any, v: any) => { if (err) { @@ -46,19 +45,19 @@ export class Cache { } public set(key: string, value: string): Promise { - let ep = this.endpoint.get(); + const ep = this.endpoint.get(); console.log(`Setting key '${key}' to '${value}' on Redis@${ep.hostname}:${ep.port}`); - let client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); + const client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); return new Promise((resolve, reject) => { client.set(key, value, (err: any, v: any) => { if (err) { reject(err); } else { - console.log("Set succeed: " + JSON.stringify(v)) + console.log("Set succeed: " + JSON.stringify(v)); resolve(); } }); }); - }; + } } diff --git a/aws-ts-url-shortener-cache-http/config.ts b/aws-ts-url-shortener-cache-http/config.ts index d9279c9cb..a7fed14fb 100644 --- a/aws-ts-url-shortener-cache-http/config.ts +++ b/aws-ts-url-shortener-cache-http/config.ts @@ -1,8 +1,8 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as pulumi from "@pulumi/pulumi"; -let config = new pulumi.Config(); +const config = new pulumi.Config(); // Get the Redis password from config export let redisPassword = config.require("redisPassword"); diff --git a/aws-ts-url-shortener-cache-http/index.ts b/aws-ts-url-shortener-cache-http/index.ts index ef1f49285..5565820f3 100644 --- a/aws-ts-url-shortener-cache-http/index.ts +++ b/aws-ts-url-shortener-cache-http/index.ts @@ -1,10 +1,11 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; import * as cloud from "@pulumi/cloud-aws"; -import * as cache from "./cache"; +import * as pulumi from "@pulumi/pulumi"; + import * as express from "express"; +import * as cache from "./cache"; type AsyncRequestHandler = (req: express.Request, res: express.Response, next: express.NextFunction) => Promise; @@ -12,22 +13,22 @@ const asyncMiddleware = (fn: AsyncRequestHandler) => { return (req: express.Request, res: express.Response, next: express.NextFunction) => { Promise.resolve(fn(req, res, next)).catch(next); }; -} +}; // Create a table `urls`, with `name` as primary key. -let urlTable = new aws.dynamodb.Table("urls", { +const urlTable = new aws.dynamodb.Table("urls", { attributes: [{ name: "name", type: "S", }], hashKey: "name", billingMode: "PAY_PER_REQUEST", -}) +}); async function scanTable() { const items: any[] = []; const db = new aws.sdk.DynamoDB.DocumentClient(); - let params = { + const params = { TableName: urlTable.name.get(), ConsistentRead: true, ExclusiveStartKey: undefined, @@ -47,16 +48,16 @@ async function scanTable() { } // Create a cache of frequently accessed urls. -let urlCache = new cache.Cache("urlcache"); +const urlCache = new cache.Cache("urlcache"); // Create a web server. -let httpServer = new cloud.HttpServer("urlshortener", () => { - let app = express(); +const httpServer = new cloud.HttpServer("urlshortener", () => { + const app = express(); // GET /url lists all URLs currently registered. app.get("/url", asyncMiddleware(async (req, res) => { try { - let items = await scanTable(); + const items = await scanTable(); res.status(200).json(items); console.log(`GET /url retrieved ${items.length} items`); } catch (err) { @@ -67,7 +68,7 @@ let httpServer = new cloud.HttpServer("urlshortener", () => { // GET /url/{name} redirects to the target URL based on a short-name. app.get("/url/:name", asyncMiddleware(async (req, res) => { - let name = req.params.name + const name = req.params.name; try { // First try the Redis cache. let url = await urlCache.get(name); @@ -84,7 +85,7 @@ let httpServer = new cloud.HttpServer("urlshortener", () => { ConsistentRead: true, }).promise(); - let value = result.Item; + const value = result.Item; url = value && value.url; if (url) { urlCache.set(name, url); // cache it for next time. @@ -96,12 +97,12 @@ let httpServer = new cloud.HttpServer("urlshortener", () => { res.setHeader("Location", url); res.status(302); res.end(""); - console.log(`GET /url/${name} => ${url}`) + console.log(`GET /url/${name} => ${url}`); } else { res.status(404); res.end(""); - console.log(`GET /url/${name} is missing (404)`) + console.log(`GET /url/${name} is missing (404)`); } } catch (err) { res.status(500).json(err.stack); diff --git a/aws-ts-voting-app/index.ts b/aws-ts-voting-app/index.ts index 6813ca58c..d2cb0885c 100644 --- a/aws-ts-voting-app/index.ts +++ b/aws-ts-voting-app/index.ts @@ -1,17 +1,17 @@ -// Copyright 2017, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as awsx from "@pulumi/awsx"; +import * as pulumi from "@pulumi/pulumi"; // Get the password to use for Redis from config. -let config = new pulumi.Config(); -let redisPassword = config.require("redisPassword"); -let redisPort = 6379; +const config = new pulumi.Config(); +const redisPassword = config.require("redisPassword"); +const redisPort = 6379; // The data layer for the application // Use the 'image' property to point to a pre-built Docker image. -let redisListener = new awsx.elasticloadbalancingv2.NetworkListener("voting-app-cache", { port: redisPort }); -let redisCache = new awsx.ecs.FargateService("voting-app-cache", { +const redisListener = new awsx.elasticloadbalancingv2.NetworkListener("voting-app-cache", { port: redisPort }); +const redisCache = new awsx.ecs.FargateService("voting-app-cache", { taskDefinitionArgs: { containers: { redis: { @@ -24,13 +24,13 @@ let redisCache = new awsx.ecs.FargateService("voting-app-cache", { }, }); -let redisEndpoint = redisListener.endpoint; +const redisEndpoint = redisListener.endpoint; // A custom container for the frontend, which is a Python Flask app // Use the 'build' property to specify a folder that contains a Dockerfile. // Pulumi builds the container for you and pushes to an ECR registry -let frontendListener = new awsx.elasticloadbalancingv2.NetworkListener("voting-app-frontend", { port: 80 }); -let frontend = new awsx.ecs.FargateService("voting-app-frontend", { +const frontendListener = new awsx.elasticloadbalancingv2.NetworkListener("voting-app-frontend", { port: 80 }); +const frontend = new awsx.ecs.FargateService("voting-app-frontend", { taskDefinitionArgs: { containers: { votingAppFrontend: { diff --git a/azure-ts-aks-helm/cluster.ts b/azure-ts-aks-helm/cluster.ts index 9bcb69517..3caab35fa 100644 --- a/azure-ts-aks-helm/cluster.ts +++ b/azure-ts-aks-helm/cluster.ts @@ -1,15 +1,15 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as azure from "@pulumi/azure"; import * as azuread from "@pulumi/azuread"; -import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; import * as config from "./config"; // Create the AD service principal for the K8s cluster. -let adApp = new azuread.Application("aks"); -let adSp = new azuread.ServicePrincipal("aksSp", { applicationId: adApp.applicationId }); -let adSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", { +const adApp = new azuread.Application("aks"); +const adSp = new azuread.ServicePrincipal("aksSp", { applicationId: adApp.applicationId }); +const adSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", { servicePrincipalId: adSp.id, value: config.password, endDate: "2099-01-01T00:00:00Z", diff --git a/azure-ts-aks-helm/config.ts b/azure-ts-aks-helm/config.ts index 9023ce417..0a670ea19 100644 --- a/azure-ts-aks-helm/config.ts +++ b/azure-ts-aks-helm/config.ts @@ -1,4 +1,4 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as azure from "@pulumi/azure"; import * as pulumi from "@pulumi/pulumi"; diff --git a/azure-ts-aks-helm/index.ts b/azure-ts-aks-helm/index.ts index 410121a1b..fab1e6190 100644 --- a/azure-ts-aks-helm/index.ts +++ b/azure-ts-aks-helm/index.ts @@ -1,7 +1,6 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as helm from "@pulumi/kubernetes/helm"; -import * as k8s from "@pulumi/kubernetes"; import { k8sCluster, k8sProvider } from "./cluster"; const apache = new helm.v2.Chart( @@ -9,9 +8,9 @@ const apache = new helm.v2.Chart( { repo: "bitnami", chart: "apache", - version: "1.0.0" + version: "1.0.0", }, - { providers: { kubernetes: k8sProvider } } + { providers: { kubernetes: k8sProvider } }, ); export let cluster = k8sCluster.name; @@ -19,4 +18,3 @@ export let kubeConfig = k8sCluster.kubeConfigRaw; export let serviceIP = apache .getResourceProperty("v1/Service", "apache-apache", "status") .apply(status => status.loadBalancer.ingress[0].ip); - diff --git a/azure-ts-aks-mean/cluster.ts b/azure-ts-aks-mean/cluster.ts index 9bcb69517..3caab35fa 100644 --- a/azure-ts-aks-mean/cluster.ts +++ b/azure-ts-aks-mean/cluster.ts @@ -1,15 +1,15 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as azure from "@pulumi/azure"; import * as azuread from "@pulumi/azuread"; -import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; import * as config from "./config"; // Create the AD service principal for the K8s cluster. -let adApp = new azuread.Application("aks"); -let adSp = new azuread.ServicePrincipal("aksSp", { applicationId: adApp.applicationId }); -let adSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", { +const adApp = new azuread.Application("aks"); +const adSp = new azuread.ServicePrincipal("aksSp", { applicationId: adApp.applicationId }); +const adSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", { servicePrincipalId: adSp.id, value: config.password, endDate: "2099-01-01T00:00:00Z", diff --git a/azure-ts-aks-mean/config.ts b/azure-ts-aks-mean/config.ts index 5f9919ee3..df2a6147e 100644 --- a/azure-ts-aks-mean/config.ts +++ b/azure-ts-aks-mean/config.ts @@ -1,4 +1,4 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as azure from "@pulumi/azure"; import * as pulumi from "@pulumi/pulumi"; diff --git a/azure-ts-aks-mean/index.ts b/azure-ts-aks-mean/index.ts index 9b95440f6..62780a1f9 100644 --- a/azure-ts-aks-mean/index.ts +++ b/azure-ts-aks-mean/index.ts @@ -1,7 +1,9 @@ -import * as k8s from "@pulumi/kubernetes"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; -import * as mongoHelpers from "./mongoHelpers"; +import * as k8s from "@pulumi/kubernetes"; import * as config from "./config"; +import * as mongoHelpers from "./mongoHelpers"; // Create an AKS cluster. import { k8sCluster, k8sProvider } from "./cluster"; @@ -13,14 +15,14 @@ const cosmosdb = new azure.cosmosdb.Account("cosmosDb", { consistencyPolicy: { consistencyLevel: "BoundedStaleness", maxIntervalInSeconds: 10, - maxStalenessPrefix: 200 + maxStalenessPrefix: 200, }, offerType: "Standard", enableAutomaticFailover: true, geoLocations: [ { location: config.location, failoverPriority: 0 }, - { location: config.failoverLocation, failoverPriority: 1 } - ] + { location: config.failoverLocation, failoverPriority: 1 }, + ], }); // Create secret from MongoDB connection string. @@ -28,9 +30,9 @@ const mongoConnStrings = new k8s.core.v1.Secret( "mongo-secrets", { metadata: { name: "mongo-secrets" }, - data: mongoHelpers.parseConnString(cosmosdb.connectionStrings) + data: mongoHelpers.parseConnString(cosmosdb.connectionStrings), }, - { provider: k8sProvider } + { provider: k8sProvider }, ); // Boot up nodejs Helm chart example using CosmosDB in place of in-cluster MongoDB. @@ -43,10 +45,10 @@ const node = new k8s.helm.v2.Chart( values: { serviceType: "LoadBalancer", mongodb: { install: false }, - externaldb: { ssl: true, secretName: "mongo-secrets" } - } + externaldb: { ssl: true, secretName: "mongo-secrets" }, + }, }, - { providers: { kubernetes: k8sProvider }, dependsOn: mongoConnStrings } + { providers: { kubernetes: k8sProvider }, dependsOn: mongoConnStrings }, ); // Export kubeconfig file, cluster name, and public IP address for Kubernetes application. These can diff --git a/azure-ts-aks-mean/mongoHelpers.ts b/azure-ts-aks-mean/mongoHelpers.ts index beddc9c67..47bc8bddc 100644 --- a/azure-ts-aks-mean/mongoHelpers.ts +++ b/azure-ts-aks-mean/mongoHelpers.ts @@ -1,7 +1,9 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; export function parseConnString( - conns: pulumi.Output + conns: pulumi.Output, ): pulumi.Output<{ [key: string]: string }> { // Per the official docs[1], the format of this connection string is: // @@ -47,7 +49,7 @@ export function parseConnString( port: toBase64(port), username: toBase64(username), password: toBase64(encodeURIComponent(password)), - database: toBase64(database == "" ? "test" : database) + database: toBase64(database === "" ? "test" : database), }; }); } diff --git a/azure-ts-aks-multicluster/config.ts b/azure-ts-aks-multicluster/config.ts index c8d547bd8..483a5155d 100644 --- a/azure-ts-aks-multicluster/config.ts +++ b/azure-ts-aks-multicluster/config.ts @@ -1,4 +1,4 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as azure from "@pulumi/azure"; import * as pulumi from "@pulumi/pulumi"; diff --git a/azure-ts-aks-multicluster/index.ts b/azure-ts-aks-multicluster/index.ts index 2ef44cb50..4863166c5 100644 --- a/azure-ts-aks-multicluster/index.ts +++ b/azure-ts-aks-multicluster/index.ts @@ -1,4 +1,4 @@ -// Copyright 2016-2018, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. import * as azure from "@pulumi/azure"; import * as azuread from "@pulumi/azuread"; @@ -8,13 +8,13 @@ import * as config from "./config"; // Per-cluster config const aksClusterConfig = [ { - name: 'east', + name: "east", location: azure.Locations.EastUS, nodeCount: 2, nodeSize: "Standard_D2_v2", }, { - name: 'west', + name: "west", location: azure.Locations.WestUS, nodeCount: 5, nodeSize: "Standard_D2_v2", diff --git a/azure-ts-api-management/index.ts b/azure-ts-api-management/index.ts index c25eba35b..0c66b2666 100644 --- a/azure-ts-api-management/index.ts +++ b/azure-ts-api-management/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; // Create an Azure Resource Group const resourceGroup = new azure.core.ResourceGroup("resourceGroup"); @@ -30,7 +32,7 @@ const service = new azure.apimanagement.Service("greeting-service", { capacity: 1, }, publisherName: "YourCompany", - publisherEmail: "api@yourcompany.com", + publisherEmail: "api@yourcompany.com", }); // Create the API definition and map it to the HTTP Function backend @@ -63,12 +65,12 @@ const operation = new azure.apimanagement.ApiOperation("hello", { // Define the operation policy that does two things: // 1. Rewrites the URL to put the name from the path segment to a query parameter // 2. Caches the response for 30 seconds -new azure.apimanagement.ApiOperationPolicy("hello-policy", { +const policy = new azure.apimanagement.ApiOperationPolicy("hello-policy", { resourceGroupName: resourceGroup.name, apiManagementName: service.name, apiName: api.name, operationId: operation.operationId, - xmlContent: + xmlContent: ` @@ -85,7 +87,7 @@ new azure.apimanagement.ApiOperationPolicy("hello-policy", { - ` + `, }); // Create an API Management product @@ -99,11 +101,11 @@ const product = new azure.apimanagement.Product("greeting-product", { }); // Link the API to the Product -new azure.apimanagement.ProductApi("greeting-product-api", { +const productApi = new azure.apimanagement.ProductApi("greeting-product-api", { resourceGroupName: resourceGroup.name, apiManagementName: service.name, apiName: api.name, - productId: product.productId, + productId: product.productId, }); // Create a first user for our API diff --git a/azure-ts-appservice-devops/infra/index.ts b/azure-ts-appservice-devops/infra/index.ts index 22a909772..461471952 100644 --- a/azure-ts-appservice-devops/infra/index.ts +++ b/azure-ts-appservice-devops/infra/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; diff --git a/azure-ts-appservice-docker/index.ts b/azure-ts-appservice-docker/index.ts index 9dc705947..9c9c31ba3 100644 --- a/azure-ts-appservice-docker/index.ts +++ b/azure-ts-appservice-docker/index.ts @@ -1,6 +1,8 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; import * as docker from "@pulumi/docker"; +import * as pulumi from "@pulumi/pulumi"; // Create an Azure Resource Group const resourceGroup = new azure.core.ResourceGroup("samples", { diff --git a/azure-ts-appservice-springboot/infrastructure/index.ts b/azure-ts-appservice-springboot/infrastructure/index.ts index 1f4706296..75dbd8c05 100644 --- a/azure-ts-appservice-springboot/infrastructure/index.ts +++ b/azure-ts-appservice-springboot/infrastructure/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; import * as docker from "@pulumi/docker"; diff --git a/azure-ts-appservice/index.ts b/azure-ts-appservice/index.ts index cedcdff15..c716648b0 100644 --- a/azure-ts-appservice/index.ts +++ b/azure-ts-appservice/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; // use first 10 characters of the stackname as prefix for resource names const prefix = pulumi.getStack().substring(0, 9); @@ -47,7 +49,7 @@ const blob = new azure.storage.ZipBlob(`${prefix}-b`, { storageContainerName: storageContainer.name, type: "block", - content: new pulumi.asset.FileArchive("wwwroot") + content: new pulumi.asset.FileArchive("wwwroot"), }); const codeBlobUrl = azure.storage.signedBlobReadUrl(blob, storageAccount); @@ -55,7 +57,7 @@ const codeBlobUrl = azure.storage.signedBlobReadUrl(blob, storageAccount); const appInsights = new azure.appinsights.Insights(`${prefix}-ai`, { ...resourceGroupArgs, - applicationType: "Web" + applicationType: "Web", }); const username = "pulumi"; @@ -75,7 +77,7 @@ const sqlServer = new azure.sql.SqlServer(`${prefix}-sql`, { const database = new azure.sql.Database(`${prefix}-db`, { ...resourceGroupArgs, serverName: sqlServer.name, - requestedServiceObjectiveName: "S0" + requestedServiceObjectiveName: "S0", }); const app = new azure.appservice.AppService(`${prefix}-as`, { @@ -87,7 +89,7 @@ const app = new azure.appservice.AppService(`${prefix}-as`, { appSettings: { "WEBSITE_RUN_FROM_ZIP": codeBlobUrl, "ApplicationInsights:InstrumentationKey": appInsights.instrumentationKey, - "APPINSIGHTS_INSTRUMENTATIONKEY": appInsights.instrumentationKey + "APPINSIGHTS_INSTRUMENTATIONKEY": appInsights.instrumentationKey, }, connectionStrings: [{ @@ -95,8 +97,8 @@ const app = new azure.appservice.AppService(`${prefix}-as`, { value: pulumi.all([sqlServer.name, database.name]).apply(([server, db]) => `Server=tcp:${server}.database.windows.net;initial catalog=${db};user ID=${username};password=${pwd};Min Pool Size=0;Max Pool Size=30;Persist Security Info=true;`), - type: "SQLAzure" - }] + type: "SQLAzure", + }], }); -exports.endpoint = pulumi.interpolate `https://${app.defaultSiteHostname}`; +export const endpoint = pulumi.interpolate `https://${app.defaultSiteHostname}`; diff --git a/azure-ts-arm-template/index.ts b/azure-ts-arm-template/index.ts index ed23b96c7..434f79169 100644 --- a/azure-ts-arm-template/index.ts +++ b/azure-ts-arm-template/index.ts @@ -1,7 +1,7 @@ // Copyright 2016-2018, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; // Create a resource group to deploy all ARM template resources into. const resourceGroup = new azure.core.ResourceGroup("test", { location: azure.Locations.WestUS }); @@ -19,12 +19,12 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", { "allowedValues": [ "Standard_LRS", "Standard_GRS", - "Standard_ZRS" + "Standard_ZRS", ], "metadata": { - "description": "Storage Account type" - } - } + "description": "Storage Account type", + }, + }, }, "variables": { "location": "[resourceGroup().location]", @@ -32,7 +32,7 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", { "publicIPAddressName": "[concat('myPublicIp', uniquestring(resourceGroup().id))]", "publicIPAddressType": "Dynamic", "apiVersion": "2015-06-15", - "dnsLabelPrefix": `${pulumi.getProject()}-${pulumi.getStack()}` + "dnsLabelPrefix": `${pulumi.getProject()}-${pulumi.getStack()}`, }, "resources": [ { @@ -41,8 +41,8 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", { "apiVersion": "[variables('apiVersion')]", "location": "[variables('location')]", "properties": { - "accountType": "[parameters('storageAccountType')]" - } + "accountType": "[parameters('storageAccountType')]", + }, }, { "type": "Microsoft.Network/publicIPAddresses", @@ -52,17 +52,17 @@ const armDeployment = new azure.core.TemplateDeployment("test-dep", { "properties": { "publicIPAllocationMethod": "[variables('publicIPAddressType')]", "dnsSettings": { - "domainNameLabel": "[variables('dnsLabelPrefix')]" - } - } - } + "domainNameLabel": "[variables('dnsLabelPrefix')]", + }, + }, + }, ], "outputs": { "storageAccountName": { "type": "string", - "value": "[variables('storageAccountName')]" - } - } + "value": "[variables('storageAccountName')]", + }, + }, }), parameters: { "storageAccountType": "Standard_GRS", diff --git a/azure-ts-dynamicresource/cdnCustomDomain.ts b/azure-ts-dynamicresource/cdnCustomDomain.ts index 32c1cabe2..1ca740e4d 100644 --- a/azure-ts-dynamicresource/cdnCustomDomain.ts +++ b/azure-ts-dynamicresource/cdnCustomDomain.ts @@ -1,11 +1,11 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; -import * as msRestAzure from "@azure/ms-rest-nodeauth"; import * as cdnManagement from "@azure/arm-cdn"; import { ServiceClientCredentials } from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-nodeauth"; /** * CustomDomainOptions represents the inputs to the dynamic resource. @@ -148,7 +148,7 @@ class CDNCustomDomainResourceProvider implements pulumi.dynamic.ResourceProvider return { deleteBeforeReplace: deleteBeforeReplace, replaces: replaces, - changes: changes + changes: changes, }; } @@ -213,7 +213,7 @@ class CDNCustomDomainResourceProvider implements pulumi.dynamic.ResourceProvider if (!result.resourceState) { return; } - if (result.resourceState !== 'Deleting') { + if (result.resourceState !== "Deleting") { throw new Error(`Provisioning state of the custom domain was expected to be 'Deleting', but was ${result.resourceState}.`); } @@ -255,7 +255,7 @@ class CDNCustomDomainResourceProvider implements pulumi.dynamic.ResourceProvider * CDNCustomDomainResource is a resource that can be used to create * custom domains against Azure CDN resources. * The Azure CDN resource itself must exist in order to create a custom domain for it. - * + * * Outputs from the dynamic resource provider must be declared in the dynamic resource itself * as `public readonly` members with the type `Output`. These are automatically set by the dynamic * provider engine. The names of these properties must match the names of the properties exactly as diff --git a/azure-ts-dynamicresource/index.ts b/azure-ts-dynamicresource/index.ts index eba4b2551..a411bc334 100644 --- a/azure-ts-dynamicresource/index.ts +++ b/azure-ts-dynamicresource/index.ts @@ -1,7 +1,7 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; import { CDNCustomDomainResource } from "./cdnCustomDomain"; @@ -51,7 +51,7 @@ const cdnEndpoint = new azure.cdn.Endpoint("cdnEndpoint", { * so you can add a CNAME record for your custom domain * pointing to this CDN endpoint to it. * - * For example, the URL for this CDN endpoint when it is created + * For example, the URL for this CDN endpoint when it is created * would be `my-cdn-endpoint.azureedge.net`. */ name: "my-cdn-endpoint", @@ -78,8 +78,8 @@ const cdnEndpoint = new azure.cdn.Endpoint("cdnEndpoint", { name: "cdn-origin", hostName: storageAccount.primaryBlobHost, httpsPort: 443, - } - ] + }, + ], }); export const cdnEndpointUrl = pulumi.interpolate`https://${cdnEndpoint.hostName}`; @@ -93,7 +93,7 @@ export const cdnCustomDomainResource = new CDNCustomDomainResource("cdnCustomDom endpointName: cdnEndpoint.name, /** * This will enable HTTPS through Azure's one-click - * automated certificate deployment. The certificate is + * automated certificate deployment. The certificate is * fully managed by Azure from provisioning to automatic renewal * at no additional cost to you. */ diff --git a/azure-ts-functions-raw/index.ts b/azure-ts-functions-raw/index.ts index 2a9ba34b4..c9f81594d 100644 --- a/azure-ts-functions-raw/index.ts +++ b/azure-ts-functions-raw/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; // Create a resource group for Windows App Service Plan const resourceGroup = new azure.core.ResourceGroup("windowsrg"); diff --git a/azure-ts-functions/index.ts b/azure-ts-functions/index.ts index ee1a46653..f544ea41d 100644 --- a/azure-ts-functions/index.ts +++ b/azure-ts-functions/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; const resourceGroup = new azure.core.ResourceGroup("example"); @@ -6,7 +8,7 @@ const resourceGroup = new azure.core.ResourceGroup("example"); async function handler(context: azure.appservice.Context, request: azure.appservice.HttpRequest) { let body = ""; const headers = request.headers; - for (const h in request.headers) { + for (const h of Object.keys(request.headers)) { body = body + `${h} = ${headers[h]}\n`; } @@ -19,9 +21,9 @@ async function handler(context: azure.appservice.Context id.principalId || "11111111-1111-1111-1111-111111111111"); // Grant App Service access to KV secrets -new azure.keyvault.AccessPolicy("app-policy", { +const policy = new azure.keyvault.AccessPolicy("app-policy", { keyVaultId: vault.id, tenantId: tenantId, objectId: principalId, @@ -157,13 +159,13 @@ const blobPermission = new azure.role.Assignment("readblob", { // Add SQL firewall exceptions const firewallRules = app.outboundIpAddresses.apply( - ips => ips.split(',').map( + ips => ips.split(",").map( ip => new azure.sql.FirewallRule(`FR${ip}`, { resourceGroupName: resourceGroup.name, startIpAddress: ip, endIpAddress: ip, serverName: sqlServer.name, - }) + }), )); export const endpoint = pulumi.interpolate `https://${app.defaultSiteHostname}`; diff --git a/azure-ts-serverless-url-shortener-global/cosmosclient.ts b/azure-ts-serverless-url-shortener-global/cosmosclient.ts index 0543e0276..213126d1e 100644 --- a/azure-ts-serverless-url-shortener-global/cosmosclient.ts +++ b/azure-ts-serverless-url-shortener-global/cosmosclient.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as cosmos from "@azure/cosmos"; export async function getContainer(endpoint: string, masterKey: string, region: string) { diff --git a/azure-ts-serverless-url-shortener-global/index.ts b/azure-ts-serverless-url-shortener-global/index.ts index a630fbfce..cb5874dc0 100644 --- a/azure-ts-serverless-url-shortener-global/index.ts +++ b/azure-ts-serverless-url-shortener-global/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import { Container } from "@azure/cosmos"; import * as azure from "@pulumi/azure"; import * as pulumi from "@pulumi/pulumi"; @@ -47,7 +49,7 @@ const profile = new azure.trafficmanager.Profile("UrlShortEndpoint", { protocol: "HTTP", port: 80, path: "/api/ping", - }] + }], }); // Azure Function to accept new URL shortcodes and save to Cosmos DB @@ -66,7 +68,7 @@ const fn = new azure.appservice.HttpEventSubscription("AddUrl", { await container.items.create(request.body); return { status: 200, body: "Short URL saved" }; }; - } + }, }); export const addEndpoint = fn.url; @@ -100,19 +102,19 @@ for (const location of locations) { : { status: 404, body: "" }; } catch (e) { // Cosmos SDK throws an error for non-existing documents - return { status: 404, body: "" } + return { status: 404, body: "" }; } }; - } + }, }); const app = fn.functionApp; // An endpoint per region for Traffic Manager, link to the corresponding Function App - new azure.trafficmanager.Endpoint(`tme${location}`, { + const endpoint = new azure.trafficmanager.Endpoint(`tme${location}`, { resourceGroupName: resourceGroup.name, profileName: profile.name, - type: 'azureEndpoints', + type: "azureEndpoints", targetResourceId: app.id, target: app.defaultHostname, endpointLocation: app.location, diff --git a/azure-ts-static-website/index.ts b/azure-ts-static-website/index.ts index 6cf1b2516..bbe0da32f 100644 --- a/azure-ts-static-website/index.ts +++ b/azure-ts-static-website/index.ts @@ -1,7 +1,7 @@ // Copyright 2016-2018, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; import { StorageStaticWebsite } from "./staticWebsite"; // Create an Azure Resource Group @@ -24,7 +24,7 @@ const staticWebsite = new StorageStaticWebsite("website-static", { }); // Upload the files -["index.html", "404.html"].map(name => +["index.html", "404.html"].map(name => new azure.storage.Blob(name, { name, resourceGroupName: resourceGroup.name, @@ -33,7 +33,7 @@ const staticWebsite = new StorageStaticWebsite("website-static", { type: "block", source: `./wwwroot/${name}`, contentType: "text/html", - }) + }), ); // Web endpoint to the website @@ -55,6 +55,6 @@ const endpoint = new azure.cdn.Endpoint("website-cdn-ep", { }], }); -// CDN endpoint to the website. +// CDN endpoint to the website. // Allow it some time after the deployment to get ready. export const cdnEndpoint = pulumi.interpolate`https://${endpoint.hostName}/`; diff --git a/azure-ts-static-website/staticWebsite.ts b/azure-ts-static-website/staticWebsite.ts index 056623c0c..3e74617d1 100644 --- a/azure-ts-static-website/staticWebsite.ts +++ b/azure-ts-static-website/staticWebsite.ts @@ -34,7 +34,7 @@ class StorageStaticWebsiteProvider implements pulumi.dynamic.ResourceProvider { public async create(inputs: any): Promise { const { execSync } = require("child_process"); - const url = require('url'); + const url = require("url"); const accountName = inputs[accountNameProp]; // Helper function to execute a command, supress the warnings from polluting the output, and parse the result as JSON @@ -50,15 +50,15 @@ class StorageStaticWebsiteProvider implements pulumi.dynamic.ResourceProvider { } // Extract the web endpoint and the hostname from the storage account - const endpoint = executeToJson(`az storage account show -n "${accountName}" --query "primaryEndpoints.web"`); + const endpoint = executeToJson(`az storage account show -n "${accountName}" --query "primaryEndpoints.web"`); const hostName = url.parse(endpoint).hostname; // Files for static websites should be stored in a special built-in container called '$web', see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website const webContainerName = "$web"; - return { + return { id: `${accountName}StaticWebsite`, - outs: { endpoint, hostName, webContainerName } + outs: { endpoint, hostName, webContainerName }, }; } } diff --git a/azure-ts-stream-analytics/index.ts b/azure-ts-stream-analytics/index.ts index 43bb84560..75b544b45 100644 --- a/azure-ts-stream-analytics/index.ts +++ b/azure-ts-stream-analytics/index.ts @@ -1,7 +1,7 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; import { createSharedAccessToken } from "./token"; // Create an Azure Resource Group @@ -54,7 +54,7 @@ FROM GROUP BY Make, TumblingWindow(minute, 1) -` +`, }); // Input of the job: the Event Hub with raw events diff --git a/azure-ts-stream-analytics/token.ts b/azure-ts-stream-analytics/token.ts index b22eb00d2..a15a3c9b6 100644 --- a/azure-ts-stream-analytics/token.ts +++ b/azure-ts-stream-analytics/token.ts @@ -1,16 +1,18 @@ -import { encode } from "utf8"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import { createHmac } from "crypto"; +import { encode } from "utf8"; export function createSharedAccessToken(uri: string, saName: string, saKey: string): string { if (!uri || !saName || !saKey) { throw "Missing required parameter"; } - var encoded = encodeURIComponent(uri); - var now = new Date(); - var week = 60 * 60 * 24 * 7; - var ttl = Math.round(now.getTime() / 1000) + week; - var signature = encoded + '\n' + ttl; - var signatureUTF8 = encode(signature); - var hash = createHmac('sha256', saKey).update(signatureUTF8).digest('base64'); - return 'SharedAccessSignature sr=' + encoded + '&sig=' + encodeURIComponent(hash) + '&se=' + ttl + '&skn=' + saName; + const encoded = encodeURIComponent(uri); + const now = new Date(); + const week = 60 * 60 * 24 * 7; + const ttl = Math.round(now.getTime() / 1000) + week; + const signature = encoded + "\n" + ttl; + const signatureUTF8 = encode(signature); + const hash = createHmac("sha256", saKey).update(signatureUTF8).digest("base64"); + return "SharedAccessSignature sr=" + encoded + "&sig=" + encodeURIComponent(hash) + "&se=" + ttl + "&skn=" + saName; } diff --git a/azure-ts-webserver-component/index.ts b/azure-ts-webserver-component/index.ts index 791f0c3d9..553640378 100644 --- a/azure-ts-webserver-component/index.ts +++ b/azure-ts-webserver-component/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; import { WebServer } from "./webserver"; // Get the desired username and password for our webserver VMs. diff --git a/azure-ts-webserver-component/webserver.ts b/azure-ts-webserver-component/webserver.ts index 60a99d8cf..5bf565ae9 100644 --- a/azure-ts-webserver-component/webserver.ts +++ b/azure-ts-webserver-component/webserver.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; /** * WebServer is a reusable web server component that creates and exports a NIC, public IP, and VM. diff --git a/azure-ts-webserver/index.ts b/azure-ts-webserver/index.ts index c0a230798..be850a9c4 100644 --- a/azure-ts-webserver/index.ts +++ b/azure-ts-webserver/index.ts @@ -1,5 +1,7 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as azure from "@pulumi/azure"; +import * as pulumi from "@pulumi/pulumi"; // Get the desired username and password for our VM. const config = new pulumi.Config(); diff --git a/cloud-ts-url-shortener-cache-http/cache.ts b/cloud-ts-url-shortener-cache-http/cache.ts index 1f14c8c7f..09526ae6a 100644 --- a/cloud-ts-url-shortener-cache-http/cache.ts +++ b/cloud-ts-url-shortener-cache-http/cache.ts @@ -6,8 +6,8 @@ // you full access to the breadth of the platform's capabilities and comes with many abstractions to // make developing against that platform easier. -import * as pulumi from "@pulumi/pulumi"; import * as cloud from "@pulumi/cloud"; +import * as pulumi from "@pulumi/pulumi"; import * as config from "./config"; // A simple cache abstraction that wraps Redis. @@ -16,7 +16,7 @@ export class Cache { private readonly endpoint: pulumi.Output; constructor(name: string, memory: number = 128) { - let pw = config.redisPassword; + const pw = config.redisPassword; this.redis = new cloud.Service(name, { containers: { redis: { @@ -32,10 +32,10 @@ export class Cache { } public get(key: string): Promise { - let ep = this.endpoint.get(); + const ep = this.endpoint.get(); console.log(`Getting key '${key}' on Redis@${ep.hostname}:${ep.port}`); - let client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); + const client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); return new Promise((resolve, reject) => { client.get(key, (err: any, v: any) => { if (err) { @@ -48,19 +48,19 @@ export class Cache { } public set(key: string, value: string): Promise { - let ep = this.endpoint.get(); + const ep = this.endpoint.get(); console.log(`Setting key '${key}' to '${value}' on Redis@${ep.hostname}:${ep.port}`); - let client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); + const client = require("redis").createClient(ep.port, ep.hostname, { password: config.redisPassword }); return new Promise((resolve, reject) => { client.set(key, value, (err: any, v: any) => { if (err) { reject(err); } else { - console.log("Set succeeed: " + JSON.stringify(v)) + console.log("Set succeeed: " + JSON.stringify(v)); resolve(); } }); }); - }; + } } diff --git a/cloud-ts-url-shortener-cache-http/config.ts b/cloud-ts-url-shortener-cache-http/config.ts index d9279c9cb..682867d00 100644 --- a/cloud-ts-url-shortener-cache-http/config.ts +++ b/cloud-ts-url-shortener-cache-http/config.ts @@ -2,7 +2,7 @@ import * as pulumi from "@pulumi/pulumi"; -let config = new pulumi.Config(); +const config = new pulumi.Config(); // Get the Redis password from config -export let redisPassword = config.require("redisPassword"); +export const redisPassword = config.require("redisPassword"); diff --git a/cloud-ts-url-shortener-cache-http/index.ts b/cloud-ts-url-shortener-cache-http/index.ts index e83b675d3..3011342f0 100644 --- a/cloud-ts-url-shortener-cache-http/index.ts +++ b/cloud-ts-url-shortener-cache-http/index.ts @@ -6,12 +6,11 @@ // you full access to the breadth of the platform's capabilities and comes with many abstractions to // make developing against that platform easier. -import * as pulumi from "@pulumi/pulumi"; import * as cloud from "@pulumi/cloud"; -import * as cache from "./cache"; +import * as pulumi from "@pulumi/pulumi"; + import * as express from "express"; -import * as fs from "fs"; -import * as mime from "mime-types"; +import * as cache from "./cache"; type AsyncRequestHandler = (req: express.Request, res: express.Response, next: express.NextFunction) => Promise; @@ -19,22 +18,22 @@ const asyncMiddleware = (fn: AsyncRequestHandler) => { return (req: express.Request, res: express.Response, next: express.NextFunction) => { Promise.resolve(fn(req, res, next)).catch(next); }; -} +}; // Create a table `urls`, with `name` as primary key. -let urlTable = new cloud.Table("urls", "name"); +const urlTable = new cloud.Table("urls", "name"); // Create a cache of frequently accessed urls. -let urlCache = new cache.Cache("urlcache"); +const urlCache = new cache.Cache("urlcache"); // Create a web server. -let endpoint = new cloud.HttpServer("urlshortener", () => { - let app = express(); +const endpoint = new cloud.HttpServer("urlshortener", () => { + const app = express(); // GET /url lists all URLs currently registered. app.get("/url", asyncMiddleware(async (req, res) => { try { - let items = await urlTable.scan(); + const items = await urlTable.scan(); res.status(200).json(items); console.log(`GET /url retrieved ${items.length} items`); } catch (err) { @@ -45,7 +44,7 @@ let endpoint = new cloud.HttpServer("urlshortener", () => { // GET /url/{name} redirects to the target URL based on a short-name. app.get("/url/:name", asyncMiddleware(async (req, res) => { - let name = req.params.name + const name = req.params.name; try { // First try the Redis cache. let url = await urlCache.get(name); @@ -55,7 +54,7 @@ let endpoint = new cloud.HttpServer("urlshortener", () => { } else { // If we didn't find it in the cache, consult the table. - let value = await urlTable.get({name}); + const value = await urlTable.get({name}); url = value && value.url; if (url) { urlCache.set(name, url); // cache it for next time. @@ -67,12 +66,12 @@ let endpoint = new cloud.HttpServer("urlshortener", () => { res.setHeader("Location", url); res.status(302); res.end(""); - console.log(`GET /url/${name} => ${url}`) + console.log(`GET /url/${name} => ${url}`); } else { res.status(404); res.end(""); - console.log(`GET /url/${name} is missing (404)`) + console.log(`GET /url/${name} is missing (404)`); } } catch (err) { res.status(500).json(err.stack); @@ -110,32 +109,4 @@ let endpoint = new cloud.HttpServer("urlshortener", () => { return app; }); -function staticRoutes(app: express.Express, path: string, root: string) { - for (const child of fs.readdirSync("./" + root)) { - app.get(path + child, (req, res) => { - try - { - // console.log("Trying to serve: " + path + child) - // res.json({ serving: child }); - const localPath = "./" + root + "/" + child; - const contents = fs.readFileSync(localPath); - - var type = mime.contentType(child) - if (type) { - res.setHeader('Content-Type', type); - } - - const stat = fs.statSync(path); - - res.setHeader("Content-Length", stat.size); - res.end(contents); - } - catch (err) { - console.log(JSON.stringify({ message: err.message, stack: err.stack })); - res.json({ message: err.message, stack: err.stack }); - } - }); - } -} - export let endpointUrl = pulumi.interpolate `${endpoint.url}index.html`; diff --git a/cloud-ts-url-shortener-cache/cache.ts b/cloud-ts-url-shortener-cache/cache.ts index 0eba6c3fe..95ce881c0 100644 --- a/cloud-ts-url-shortener-cache/cache.ts +++ b/cloud-ts-url-shortener-cache/cache.ts @@ -17,7 +17,7 @@ export class Cache { private readonly redis: cloud.Service; constructor(name: string, memory: number = 128) { - let pw = config.redisPassword; + const pw = config.redisPassword; this.redis = new cloud.Service(name, { containers: { redis: { @@ -29,12 +29,12 @@ export class Cache { }, }); - let endpoint = this.redis.endpoints.redis[6379]; + const endpoint = this.redis.endpoints.redis[6379]; this.get = async (key: string) => { - let ep = (await endpoint).get(); + const ep = (await endpoint).get(); console.log(`Getting key '${key}' on Redis@${ep.hostname}:${ep.port}`); - let client = require("redis").createClient(ep.port, ep.hostname, { password: pw }); + const client = require("redis").createClient(ep.port, ep.hostname, { password: pw }); return new Promise((resolve, reject) => { client.get(key, (err: any, v: any) => { if (err) { @@ -47,16 +47,16 @@ export class Cache { }; this.set = async (key: string, value: string) => { - let ep = (await endpoint).get(); + const ep = (await endpoint).get(); console.log(`Setting key '${key}' to '${value}' on Redis@${ep.hostname}:${ep.port}`); - let client = require("redis").createClient(ep.port, ep.hostname, { password: pw }); + const client = require("redis").createClient(ep.port, ep.hostname, { password: pw }); return new Promise((resolve, reject) => { client.set(key, value, (err: any, v: any) => { if (err) { reject(err); } else { - console.log("Set succeeed: " + JSON.stringify(v)) + console.log("Set succeeed: " + JSON.stringify(v)); resolve(); } }); diff --git a/cloud-ts-url-shortener-cache/config.ts b/cloud-ts-url-shortener-cache/config.ts index d9279c9cb..682867d00 100644 --- a/cloud-ts-url-shortener-cache/config.ts +++ b/cloud-ts-url-shortener-cache/config.ts @@ -2,7 +2,7 @@ import * as pulumi from "@pulumi/pulumi"; -let config = new pulumi.Config(); +const config = new pulumi.Config(); // Get the Redis password from config -export let redisPassword = config.require("redisPassword"); +export const redisPassword = config.require("redisPassword"); diff --git a/cloud-ts-url-shortener-cache/index.ts b/cloud-ts-url-shortener-cache/index.ts index d11e131de..54178ab5e 100644 --- a/cloud-ts-url-shortener-cache/index.ts +++ b/cloud-ts-url-shortener-cache/index.ts @@ -6,18 +6,17 @@ // you full access to the breadth of the platform's capabilities and comes with many abstractions to // make developing against that platform easier. -import * as pulumi from "@pulumi/pulumi"; import * as cloud from "@pulumi/cloud"; import * as cache from "./cache"; // Create a web server. -let endpoint = new cloud.HttpEndpoint("urlshortener"); +const endpoint = new cloud.HttpEndpoint("urlshortener"); // Create a table `urls`, with `name` as primary key. -let urlTable = new cloud.Table("urls", "name"); +const urlTable = new cloud.Table("urls", "name"); // Create a cache of frequently accessed urls. -let urlCache = new cache.Cache("urlcache"); +const urlCache = new cache.Cache("urlcache"); // Serve all files in the www directory to the root. endpoint.static("/", "www"); @@ -25,7 +24,7 @@ endpoint.static("/", "www"); // GET /url lists all URLs currently registered. endpoint.get("/url", async (req, res) => { try { - let items = await urlTable.scan(); + const items = await urlTable.scan(); res.status(200).json(items); console.log(`GET /url retrieved ${items.length} items`); } catch (err) { @@ -36,7 +35,7 @@ endpoint.get("/url", async (req, res) => { // GET /url/{name} redirects to the target URL based on a short-name. endpoint.get("/url/{name}", async (req, res) => { - let name = req.params["name"]; + const name = req.params["name"]; try { // First try the Redis cache. let url = await urlCache.get(name); @@ -46,7 +45,7 @@ endpoint.get("/url/{name}", async (req, res) => { } else { // If we didn't find it in the cache, consult the table. - let value = await urlTable.get({name}); + const value = await urlTable.get({name}); url = value && value.url; if (url) { urlCache.set(name, url); // cache it for next time. @@ -58,12 +57,12 @@ endpoint.get("/url/{name}", async (req, res) => { res.setHeader("Location", url); res.status(302); res.end(""); - console.log(`GET /url/${name} => ${url}`) + console.log(`GET /url/${name} => ${url}`); } else { res.status(404); res.end(""); - console.log(`GET /url/${name} is missing (404)`) + console.log(`GET /url/${name} is missing (404)`); } } catch (err) { res.status(500).json(err.stack); @@ -73,8 +72,8 @@ endpoint.get("/url/{name}", async (req, res) => { // POST /url registers a new URL with a given short-name. endpoint.post("/url", async (req, res) => { - let url = req.query["url"]; - let name = req.query["name"]; + const url = req.query["url"]; + const name = req.query["name"]; try { await urlTable.insert({ name, url }); await urlCache.set(name, url); diff --git a/cloud-ts-url-shortener/index.ts b/cloud-ts-url-shortener/index.ts index 8f608e119..5474edb0a 100644 --- a/cloud-ts-url-shortener/index.ts +++ b/cloud-ts-url-shortener/index.ts @@ -7,13 +7,12 @@ // make developing against that platform easier. import * as cloud from "@pulumi/cloud-aws"; -import { Output } from "@pulumi/pulumi"; // for output property // Create a web server. -let endpoint = new cloud.API("urlshortener"); +const endpoint = new cloud.API("urlshortener"); // Create a table `urls`, with `name` as primary key. -let urlTable = new cloud.Table("urls", "name"); +const urlTable = new cloud.Table("urls", "name"); // Serve all files in the www directory to the root. endpoint.static("/", "www"); @@ -21,7 +20,7 @@ endpoint.static("/", "www"); // GET /url lists all URLs currently registered. endpoint.get("/url", async (req, res) => { try { - let items = await urlTable.scan(); + const items = await urlTable.scan(); res.status(200).json(items); console.log(`GET /url retrieved ${items.length} items`); } catch (err) { @@ -32,22 +31,22 @@ endpoint.get("/url", async (req, res) => { // GET /url/{name} redirects to the target URL based on a short-name. endpoint.get("/url/{name}", async (req, res) => { - let name = req.params["name"]; + const name = req.params["name"]; try { - let value = await urlTable.get({name}); - let url = value && value.url; + const value = await urlTable.get({name}); + const url = value && value.url; // If we found an entry, 301 redirect to it; else, 404. if (url) { res.setHeader("Location", url); res.status(301); res.end(""); - console.log(`GET /url/${name} => ${url}`) + console.log(`GET /url/${name} => ${url}`); } else { res.status(404); res.end(""); - console.log(`GET /url/${name} is missing (404)`) + console.log(`GET /url/${name} is missing (404)`); } } catch (err) { res.status(500).json(err.stack); @@ -57,8 +56,8 @@ endpoint.get("/url/{name}", async (req, res) => { // POST /url registers a new URL with a given short-name. endpoint.post("/url", async (req, res) => { - let url = req.query["url"]; - let name = req.query["name"]; + const url = req.query["url"]; + const name = req.query["name"]; try { await urlTable.insert({ name, url }); res.json({ shortenedURLName: name }); diff --git a/cloud-ts-voting-app/index.ts b/cloud-ts-voting-app/index.ts index 57b99cf89..1b527a049 100644 --- a/cloud-ts-voting-app/index.ts +++ b/cloud-ts-voting-app/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017, Pulumi Corporation. All rights reserved. +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. // Note: @pulumi/cloud is a preview package demonstrating how to create cross-cloud Pulumi // components. If you are targeting a specific cloud like AWS, Azure, or GCP, we recommend you use @@ -6,17 +6,17 @@ // you full access to the breadth of the platform's capabilities and comes with many abstractions to // make developing against that platform easier. -import * as pulumi from "@pulumi/pulumi"; import * as cloud from "@pulumi/cloud"; +import * as pulumi from "@pulumi/pulumi"; // Get the password to use for Redis from config. -let config = new pulumi.Config(); -let redisPassword = config.require("redisPassword"); -let redisPort = 6379; +const config = new pulumi.Config(); +const redisPassword = config.require("redisPassword"); +const redisPort = 6379; // The data layer for the application // Use the 'image' property to point to a pre-built Docker image. -let redisCache = new cloud.Service("voting-app-cache", { +const redisCache = new cloud.Service("voting-app-cache", { containers: { redis: { image: "redis:alpine", @@ -27,12 +27,12 @@ let redisCache = new cloud.Service("voting-app-cache", { }, }); -let redisEndpoint = redisCache.endpoints.redis[redisPort]; +const redisEndpoint = redisCache.endpoints.redis[redisPort]; // A custom container for the frontend, which is a Python Flask app // Use the 'build' property to specify a folder that contains a Dockerfile. // Pulumi builds the container for you and pushes to an ECR registry -let frontend = new cloud.Service("voting-app-frontend", { +const frontend = new cloud.Service("voting-app-frontend", { containers: { votingAppFrontend: { build: "./frontend", // path to the folder containing the Dockerfile @@ -42,8 +42,8 @@ let frontend = new cloud.Service("voting-app-frontend", { // pass the Redis container info in environment variables "REDIS": redisEndpoint.hostname, "REDIS_PORT": redisEndpoint.apply(e => e.port.toString()), - "REDIS_PWD": redisPassword - } + "REDIS_PWD": redisPassword, + }, }, }, }); diff --git a/digitalocean-ts-loadbalanced-droplets/index.ts b/digitalocean-ts-loadbalanced-droplets/index.ts index 679986cdf..9b728f37f 100644 --- a/digitalocean-ts-loadbalanced-droplets/index.ts +++ b/digitalocean-ts-loadbalanced-droplets/index.ts @@ -1,4 +1,5 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as digitalocean from "@pulumi/digitalocean"; const dropletCount = 3; @@ -11,7 +12,7 @@ const userData = sudo apt-get install -y nginx`; const droplets = []; for (let i = 0; i < dropletCount; i++) { - let nameTag = new digitalocean.Tag(`web-${i}`); + const nameTag = new digitalocean.Tag(`web-${i}`); droplets.push(new digitalocean.Droplet(`web-${i}`, { image: "ubuntu-18-04-x64", region: region, diff --git a/f5bigip-ts-ltm-pool/f5bigip-ec2-instance/index.ts b/f5bigip-ts-ltm-pool/f5bigip-ec2-instance/index.ts index 7b0e07464..9848a7a55 100644 --- a/f5bigip-ts-ltm-pool/f5bigip-ec2-instance/index.ts +++ b/f5bigip-ts-ltm-pool/f5bigip-ec2-instance/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; diff --git a/f5bigip-ts-ltm-pool/f5bigip-pool/index.ts b/f5bigip-ts-ltm-pool/f5bigip-pool/index.ts index f917da6bd..36ddcb4f4 100644 --- a/f5bigip-ts-ltm-pool/f5bigip-pool/index.ts +++ b/f5bigip-ts-ltm-pool/f5bigip-pool/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as f5bigip from "@pulumi/f5bigip"; diff --git a/f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts b/f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts index 33c3d7c4d..ebfbbddc6 100644 --- a/f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts +++ b/f5bigip-ts-ltm-pool/nginx-ec2-instance/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; diff --git a/gcp-ts-functions/index.ts b/gcp-ts-functions/index.ts index 673fc7cb4..bb36433ef 100644 --- a/gcp-ts-functions/index.ts +++ b/gcp-ts-functions/index.ts @@ -1,7 +1,9 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as gcp from "@pulumi/gcp"; -let greeting = new gcp.cloudfunctions.HttpCallbackFunction("greeting", (req, res) => { - res.send(`Greetings from ${req.body.name || 'Google Cloud Functions'}!`); +const greeting = new gcp.cloudfunctions.HttpCallbackFunction("greeting", (req, res) => { + res.send(`Greetings from ${req.body.name || "Google Cloud Functions"}!`); }); -export let url = greeting.httpsTriggerUrl; +export const url = greeting.httpsTriggerUrl; diff --git a/gcp-ts-gke-hello-world/index.ts b/gcp-ts-gke-hello-world/index.ts index 61d7b337d..752d1fd33 100644 --- a/gcp-ts-gke-hello-world/index.ts +++ b/gcp-ts-gke-hello-world/index.ts @@ -1,7 +1,8 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. + +import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; -import * as gcp from "@pulumi/gcp"; const name = "helloworld"; @@ -19,7 +20,7 @@ const cluster = new gcp.container.Cluster(name, { "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" + "https://www.googleapis.com/auth/monitoring", ], }, }); @@ -92,16 +93,16 @@ const deployment = new k8s.apps.v1.Deployment(name, { name: name, image: "nginx:latest", - ports: [{ name: "http", containerPort: 80 }] - } + ports: [{ name: "http", containerPort: 80 }], + }, ], - } - } + }, + }, }, }, { provider: clusterProvider, - } + }, ); // Export the Deployment name @@ -122,9 +123,9 @@ const service = new k8s.core.v1.Service(name, }, { provider: clusterProvider, - } + }, ); // Export the Service name and public LoadBalancer endpoint export const serviceName = service.metadata.name; -export const servicePublicIP = service.status.apply(s => s.loadBalancer.ingress[0].ip) +export const servicePublicIP = service.status.apply(s => s.loadBalancer.ingress[0].ip); diff --git a/gcp-ts-gke/cluster.ts b/gcp-ts-gke/cluster.ts index 0ab29fd83..c9e06e4f1 100644 --- a/gcp-ts-gke/cluster.ts +++ b/gcp-ts-gke/cluster.ts @@ -3,7 +3,7 @@ import * as gcp from "@pulumi/gcp"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; -import {masterVersion, nodeCount, nodeMachineType, password, username} from "./config"; +import { masterVersion, nodeCount, nodeMachineType, password, username } from "./config"; // Create the GKE cluster and export it. export const k8sCluster = new gcp.container.Cluster("gke-cluster", { @@ -17,7 +17,7 @@ export const k8sCluster = new gcp.container.Cluster("gke-cluster", { "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" + "https://www.googleapis.com/auth/monitoring", ], }, }); diff --git a/gcp-ts-gke/index.ts b/gcp-ts-gke/index.ts index 94972cb8a..122b97890 100644 --- a/gcp-ts-gke/index.ts +++ b/gcp-ts-gke/index.ts @@ -2,7 +2,7 @@ import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; -import { k8sProvider, k8sConfig } from "./cluster"; +import { k8sConfig, k8sProvider } from "./cluster"; // Create a canary deployment to test that this cluster works. const name = `${pulumi.getProject()}-${pulumi.getStack()}`; diff --git a/gcp-ts-serverless-raw/index.ts b/gcp-ts-serverless-raw/index.ts index 3773f432d..6dd965a84 100644 --- a/gcp-ts-serverless-raw/index.ts +++ b/gcp-ts-serverless-raw/index.ts @@ -1,7 +1,7 @@ // Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import { asset } from "@pulumi/pulumi"; import * as gcp from "@pulumi/gcp"; +import { asset } from "@pulumi/pulumi"; const bucket = new gcp.storage.Bucket("bucket"); diff --git a/gcp-ts-slackbot/index.ts b/gcp-ts-slackbot/index.ts index 0e9fc513c..80ca4abc1 100644 --- a/gcp-ts-slackbot/index.ts +++ b/gcp-ts-slackbot/index.ts @@ -1,8 +1,10 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as gcp from "@pulumi/gcp"; +import * as pulumi from "@pulumi/pulumi"; -import * as gpubsub from "@google-cloud/pubsub"; import * as gfirestore from "@google-cloud/firestore"; +import * as gpubsub from "@google-cloud/pubsub"; import * as bodyParser from "body-parser"; import * as express from "express"; @@ -31,7 +33,7 @@ interface SlackRequest { } interface UrlVerificationRequest extends SlackRequest { - type: "url_verification", + type: "url_verification"; challenge: string; } @@ -73,7 +75,7 @@ const endpoint = new gcp.cloudfunctions.HttpCallbackFunction("mentionbot", { app.post("/events", asyncMiddleware(handleIncomingHttpRequest)); return app; - } + }, }); async function handleIncomingHttpRequest(req: express.Request, res: express.Response) { @@ -96,7 +98,7 @@ async function handleIncomingHttpRequest(req: express.Request, res: express.Resp } if (!verificationToken) { - throw new Error("mentionbot:verificationToken was not provided") + throw new Error("mentionbot:verificationToken was not provided"); } if (eventRequest.token !== verificationToken) { @@ -201,7 +203,7 @@ async function onMessageEventCallback(request: EventCallbackRequest) { } const permaLink = await getPermalink(event.channel, event.event_ts); - const text = `New mention at: ${permaLink}` + const text = `New mention at: ${permaLink}`; await sendChannelMessage(snapshotData.channel, text); } @@ -209,19 +211,19 @@ async function onMessageEventCallback(request: EventCallbackRequest) { async function sendChannelMessage(channel: string, text: string) { const message = { token: slackToken, channel, text }; - await superagent.get(`https://slack.com/api/chat.postMessage?${qs.stringify(message)}`) + await superagent.get(`https://slack.com/api/chat.postMessage?${qs.stringify(message)}`); } -async function getPermalink(channel: string, message_ts: string) { - const message = { token: slackToken, channel, message_ts }; - const result = await superagent.get(`https://slack.com/api/chat.getPermalink?${qs.stringify(message)}`) +async function getPermalink(channel: string, timestamp: string) { + const message = { token: slackToken, channel, message_ts: timestamp }; + const result = await superagent.get(`https://slack.com/api/chat.getPermalink?${qs.stringify(message)}`); return JSON.parse(result.text).permalink; } async function onAppMentionEventCallback(request: EventCallbackRequest) { // Got an app_mention to @mentionbot. const event = request.event; - var promise = event.text.toLowerCase().indexOf("unsubscribe") >= 0 + const promise = event.text.toLowerCase().indexOf("unsubscribe") >= 0 ? unsubscribeFromMentions(event) : subscribeToMentions(event); @@ -246,7 +248,7 @@ async function subscribeToMentions(event: Event) { // User is subscribing. Add them from subscription table. await firestore.collection(firestoreMentionUsersCollectionName).doc(event.user).set({ - channel: event.channel + channel: event.channel, }); const text = `Hi <@${event.user}>. You've been subscribed to @ mentions. Send me an message containing 'unsubscribe' to stop receiving these notifications.`; diff --git a/kubernetes-ts-configmap-rollout/index.ts b/kubernetes-ts-configmap-rollout/index.ts index e330417d0..d86ddfe16 100644 --- a/kubernetes-ts-configmap-rollout/index.ts +++ b/kubernetes-ts-configmap-rollout/index.ts @@ -1,11 +1,13 @@ -import * as fs from "fs"; -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; +import * as fs from "fs"; // Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're // running on minikube, and if so, create only services of type ClusterIP. -let config = new pulumi.Config(); -let isMinikube = config.require("isMinikube"); +const config = new pulumi.Config(); +const isMinikube = config.require("isMinikube"); const appName = "nginx"; const appLabels = { app: appName }; @@ -14,7 +16,7 @@ const appLabels = { app: appName }; // `default.conf` file. const nginxConfig = new k8s.core.v1.ConfigMap(appName, { metadata: { labels: appLabels }, - data: { "default.conf": fs.readFileSync("default.conf").toString() } + data: { "default.conf": fs.readFileSync("default.conf").toString() }, }); const nginxConfigName = nginxConfig.metadata.apply(m => m.name); @@ -31,13 +33,13 @@ const nginx = new k8s.apps.v1beta1.Deployment(appName, { { image: "nginx:1.13.6-alpine", name: "nginx", - volumeMounts: [{ name: "nginx-configs", mountPath: "/etc/nginx/conf.d" }] - } + volumeMounts: [{ name: "nginx-configs", mountPath: "/etc/nginx/conf.d" }], + }, ], - volumes: [{ name: "nginx-configs", configMap: { name: nginxConfigName } }] - } - } - } + volumes: [{ name: "nginx-configs", configMap: { name: nginxConfigName } }], + }, + }, + }, }); // Expose proxy to the public Internet. @@ -46,8 +48,8 @@ const frontend = new k8s.core.v1.Service(appName, { spec: { type: isMinikube === "true" ? "ClusterIP" : "LoadBalancer", ports: [{ port: 80, targetPort: 80, protocol: "TCP" }], - selector: appLabels - } + selector: appLabels, + }, }); // Export the frontend IP. diff --git a/kubernetes-ts-exposed-deployment/index.ts b/kubernetes-ts-exposed-deployment/index.ts index 8ca72839a..bcea685cc 100644 --- a/kubernetes-ts-exposed-deployment/index.ts +++ b/kubernetes-ts-exposed-deployment/index.ts @@ -1,10 +1,12 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; // Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're // running on minikube, and if so, create only services of type ClusterIP. -let config = new pulumi.Config(); -let isMinikube = config.require("isMinikube"); +const config = new pulumi.Config(); +const isMinikube = config.require("isMinikube"); // nginx container, replicated 1 time. const appName = "nginx"; @@ -15,9 +17,9 @@ const nginx = new k8s.apps.v1beta1.Deployment(appName, { replicas: 1, template: { metadata: { labels: appLabels }, - spec: { containers: [{ name: appName, image: "nginx:1.15-alpine" }] } - } - } + spec: { containers: [{ name: appName, image: "nginx:1.15-alpine" }] }, + }, + }, }); // Allocate an IP to the nginx Deployment. @@ -26,8 +28,8 @@ const frontend = new k8s.core.v1.Service(appName, { spec: { type: isMinikube === "true" ? "ClusterIP" : "LoadBalancer", ports: [{ port: 80, targetPort: 80, protocol: "TCP" }], - selector: appLabels - } + selector: appLabels, + }, }); // When "done", this will print the public IP. diff --git a/kubernetes-ts-guestbook/components/index.ts b/kubernetes-ts-guestbook/components/index.ts index aa05926f7..a184842ff 100644 --- a/kubernetes-ts-guestbook/components/index.ts +++ b/kubernetes-ts-guestbook/components/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as k8sjs from "./k8sjs"; diff --git a/kubernetes-ts-guestbook/components/k8sjs.ts b/kubernetes-ts-guestbook/components/k8sjs.ts index fb427000f..2017f9bb2 100644 --- a/kubernetes-ts-guestbook/components/k8sjs.ts +++ b/kubernetes-ts-guestbook/components/k8sjs.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; import * as k8stypes from "@pulumi/kubernetes/types/input"; import * as pulumi from "@pulumi/pulumi"; diff --git a/kubernetes-ts-helm-wordpress/index.ts b/kubernetes-ts-helm-wordpress/index.ts index 7e9d4404f..737392f08 100644 --- a/kubernetes-ts-helm-wordpress/index.ts +++ b/kubernetes-ts-helm-wordpress/index.ts @@ -1,9 +1,11 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; // Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're // running on minikube, and if so, create only services of type ClusterIP. -let config = new pulumi.Config(); +const config = new pulumi.Config(); if (config.require("isMinikube") === "true") { throw new Error("This example does not yet support minikube"); } @@ -12,7 +14,7 @@ if (config.require("isMinikube") === "true") { const wordpress = new k8s.helm.v2.Chart("wpdev", { repo: "stable", version: "2.1.3", - chart: "wordpress" + chart: "wordpress", }); // Export the public IP for Wordpress. diff --git a/kubernetes-ts-jenkins/index.ts b/kubernetes-ts-jenkins/index.ts index 5ffbd72f7..af334b2ed 100644 --- a/kubernetes-ts-jenkins/index.ts +++ b/kubernetes-ts-jenkins/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; import * as jenkins from "./jenkins"; @@ -12,10 +14,10 @@ const instance = new jenkins.Instance({ name: pulumi.getStack(), credentials: { username: config.require("username"), - password: config.require("password") + password: config.require("password"), }, resources: { memory: "512Mi", - cpu: "100m" - } + cpu: "100m", + }, }); diff --git a/kubernetes-ts-jenkins/jenkins.ts b/kubernetes-ts-jenkins/jenkins.ts index 135eeb7cc..3364be024 100644 --- a/kubernetes-ts-jenkins/jenkins.ts +++ b/kubernetes-ts-jenkins/jenkins.ts @@ -1,6 +1,8 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; import * as input from "@pulumi/kubernetes/types/input"; +import * as pulumi from "@pulumi/pulumi"; function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment { const image = args.image || { @@ -21,7 +23,7 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment { selector: { matchLabels: { app: args.name, - } + }, }, template: { metadata: { @@ -35,7 +37,7 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment { name: "jenkins-data", persistentVolumeClaim: { claimName: args.name, - } + }, }, ], containers: [ @@ -90,7 +92,7 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment { { name: "jenkins-data", mountPath: "/bitnami/jenkins", - } + }, ], resources: { requests: { @@ -98,12 +100,12 @@ function createDeploymentArgs(args: JenkinsArgs): input.apps.v1.Deployment { cpu: args.resources.cpu, }, }, - } // container - ] // containers - } // spec - } // template - } // spec - } // deployment + }, // container + ], // containers + }, // spec + }, // template + }, // spec + }; // deployment } /** @@ -129,7 +131,7 @@ export class Instance extends pulumi.ComponentResource { metadata: { name: args.name, annotations: { - "volume.beta.kubernetes.io/storage-class": `${args.storageClass || "standard" }` + "volume.beta.kubernetes.io/storage-class": `${args.storageClass || "standard" }`, }, }, spec: { @@ -163,12 +165,12 @@ export class Instance extends pulumi.ComponentResource { name: "https", port: 443, targetPort: "https", - } + }, ], selector: { app: args.name, - } - } + }, + }, }, { parent: this }); // This component resource has no outputs. @@ -184,27 +186,27 @@ export interface JenkinsArgs { * The name of the instance. All Kubernetes objects will be tagged with this name * in their metadata. */ - readonly name: string, + readonly name: string; /** * Credentials for accessing the created Jenkins instance. */ - readonly credentials: JenkinsCredentials, + readonly credentials: JenkinsCredentials; /** * The Docker image to use to launch this instance of Jenkins. */ - readonly image?: JenkinsImage, + readonly image?: JenkinsImage; /** * Resource requests for this instance. */ - readonly resources: JenkinsResources, + readonly resources: JenkinsResources; /** * Storage class to use for the persistent volume claim. */ - readonly storageClass?: string, + readonly storageClass?: string; } /** @@ -214,12 +216,12 @@ export interface JenkinsCredentials { /** * Username for the root user. */ - readonly username: string, + readonly username: string; /** * Password for the root user. */ - readonly password: string, + readonly password: string; } /** @@ -229,22 +231,22 @@ export interface JenkinsImage { /** * The registry from which to draw Docker images. */ - readonly registry: string, + readonly registry: string; /** * The Docker repository name for the target image. */ - readonly repository: string, + readonly repository: string; /** * The Docker image tag for the target image. */ - readonly tag: string, + readonly tag: string; /** * Pull policy for this image. */ - readonly pullPolicy: string, + readonly pullPolicy: string; } /** diff --git a/kubernetes-ts-multicloud/aks.ts b/kubernetes-ts-multicloud/aks.ts index 0000299a6..f1726180a 100644 --- a/kubernetes-ts-multicloud/aks.ts +++ b/kubernetes-ts-multicloud/aks.ts @@ -45,7 +45,7 @@ export class AksCluster extends pulumi.ComponentResource { // Create the AD service principal for the K8s cluster. const adApp = new azuread.Application("aks", undefined, {parent: this}); const adSp = new azuread.ServicePrincipal("aksSp", { - applicationId: adApp.applicationId + applicationId: adApp.applicationId, }, {parent: this}); const adSpPassword = new azuread.ServicePrincipalPassword("aksSpPassword", { servicePrincipalId: adSp.id, @@ -60,7 +60,7 @@ export class AksCluster extends pulumi.ComponentResource { const rgNetworkRole = new azure.role.Assignment("spRole", { principalId: adSp.id, scope: resourceGroup.id, - roleDefinitionName: "Network Contributor" + roleDefinitionName: "Network Contributor", }, {parent: this}); // Create a Virtual Network for the cluster @@ -115,7 +115,7 @@ export class AksCluster extends pulumi.ComponentResource { this.staticAppIP = new azure.network.PublicIp("staticAppIP", { resourceGroupName: this.cluster.nodeResourceGroup, - allocationMethod: "Static" + allocationMethod: "Static", }, {parent: this}).ipAddress; this.registerOutputs(); diff --git a/kubernetes-ts-multicloud/app.ts b/kubernetes-ts-multicloud/app.ts index 140ac1b5b..a2a3af7ae 100644 --- a/kubernetes-ts-multicloud/app.ts +++ b/kubernetes-ts-multicloud/app.ts @@ -17,9 +17,9 @@ import * as pulumi from "@pulumi/pulumi"; // Arguments for the demo app. export interface DemoAppArgs { - provider: k8s.Provider // Provider resource for the target Kubernetes cluster. - imageTag: string // Tag for the kuard image to deploy. - staticAppIP?: pulumi.Input // Optional static IP to use for the service. (Required for AKS). + provider: k8s.Provider; // Provider resource for the target Kubernetes cluster. + imageTag: string; // Tag for the kuard image to deploy. + staticAppIP?: pulumi.Input; // Optional static IP to use for the service. (Required for AKS). } export class DemoApp extends pulumi.ComponentResource { @@ -49,20 +49,20 @@ export class DemoApp extends pulumi.ComponentResource { initialDelaySeconds: 5, timeoutSeconds: 1, periodSeconds: 10, - failureThreshold: 3 + failureThreshold: 3, }, readinessProbe: { httpGet: {path: "/ready", port: "http"}, initialDelaySeconds: 5, timeoutSeconds: 1, periodSeconds: 10, - failureThreshold: 3 - } - } + failureThreshold: 3, + }, + }, ], }, }, - } + }, }, {provider: args.provider, parent: this}); // Create a LoadBalancer Service to expose the kuard Deployment. @@ -71,8 +71,8 @@ export class DemoApp extends pulumi.ComponentResource { loadBalancerIP: args.staticAppIP, // Required for AKS - automatic LoadBalancer still in preview. selector: appLabels, ports: [{port: 80, targetPort: 8080}], - type: "LoadBalancer" - } + type: "LoadBalancer", + }, }, {provider: args.provider, parent: this}); // The address appears in different places depending on the Kubernetes service provider. diff --git a/kubernetes-ts-multicloud/gke.ts b/kubernetes-ts-multicloud/gke.ts index 423183556..c050dd1fc 100644 --- a/kubernetes-ts-multicloud/gke.ts +++ b/kubernetes-ts-multicloud/gke.ts @@ -31,7 +31,7 @@ export class GkeCluster extends pulumi.ComponentResource { // Generate a strong password for the Kubernetes cluster. const password = new random.RandomString("password", { length: 20, - special: true + special: true, }, {parent: this, additionalSecretOutputs: ["result"]}).result; // Create the GKE cluster. @@ -46,7 +46,7 @@ export class GkeCluster extends pulumi.ComponentResource { "https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", - "https://www.googleapis.com/auth/monitoring" + "https://www.googleapis.com/auth/monitoring", ], }, }, {parent: this}); diff --git a/kubernetes-ts-multicloud/index.ts b/kubernetes-ts-multicloud/index.ts index 48a0ec6d6..5af84a980 100644 --- a/kubernetes-ts-multicloud/index.ts +++ b/kubernetes-ts-multicloud/index.ts @@ -28,9 +28,9 @@ const gkeCluster = new gke.GkeCluster("multicloud", {}); // Create a list of named clusters where the demo app will be deployed. interface Cluster { - name: string - provider: k8s.Provider - staticAppIP?: pulumi.Output + name: string; + provider: k8s.Provider; + staticAppIP?: pulumi.Output; } const clusters: Cluster[] = [ // Note: Comment out lines for any cluster you don't want to deploy. @@ -41,11 +41,11 @@ const clusters: Cluster[] = [ ]; // Export a list of URLs to access the demo app. -interface appUrl { - name: string, - url: pulumi.Output +interface AppUrl { + name: string; + url: pulumi.Output; } -export let appUrls: appUrl[] = []; +export let appUrls: AppUrl[] = []; const kuardImageTag = "blue"; // const kuardImageTag = "green"; @@ -55,9 +55,9 @@ for (const cluster of clusters) { const instance = new app.DemoApp(cluster.name, { provider: cluster.provider, imageTag: kuardImageTag, - staticAppIP: cluster.staticAppIP + staticAppIP: cluster.staticAppIP, }); - let instanceUrl: appUrl = {name: cluster.name, url: instance.appUrl}; + const instanceUrl: AppUrl = {name: cluster.name, url: instance.appUrl}; appUrls = appUrls.concat(instanceUrl); } diff --git a/kubernetes-ts-nginx/index.ts b/kubernetes-ts-nginx/index.ts index 7a47e3aba..27a7e26bd 100644 --- a/kubernetes-ts-nginx/index.ts +++ b/kubernetes-ts-nginx/index.ts @@ -1,12 +1,12 @@ // Copyright 2016-2018, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; -let config = new pulumi.Config(); +const config = new pulumi.Config(); -let nginxLabels = { app: "nginx" }; -let nginxDeployment = new k8s.apps.v1.Deployment("nginx-deployment", { +const nginxLabels = { app: "nginx" }; +const nginxDeployment = new k8s.apps.v1.Deployment("nginx-deployment", { spec: { selector: { matchLabels: nginxLabels }, replicas: config.getNumber("replicas") || 2, @@ -16,11 +16,11 @@ let nginxDeployment = new k8s.apps.v1.Deployment("nginx-deployment", { containers: [{ name: "nginx", image: "nginx:1.7.9", - ports: [{ containerPort: 80 }] + ports: [{ containerPort: 80 }], }], }, }, }, }); -export let nginx = nginxDeployment.metadata.name; +export const nginx = nginxDeployment.metadata.name; diff --git a/kubernetes-ts-s3-rollout/config.ts b/kubernetes-ts-s3-rollout/config.ts index c1e083e21..ecc1c8c74 100644 --- a/kubernetes-ts-s3-rollout/config.ts +++ b/kubernetes-ts-s3-rollout/config.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as fs from "fs"; import * as aws from "@pulumi/aws"; @@ -5,21 +7,21 @@ import * as pulumi from "@pulumi/pulumi"; import * as mime from "mime"; // Create a bucket and expose a website index document -let siteBucket = new aws.s3.Bucket("s3-website-bucket", { +const siteBucket = new aws.s3.Bucket("s3-website-bucket", { website: { - indexDocument: "index.html" - } + indexDocument: "index.html", + }, }); -let siteDir = "www"; // directory for content files +const siteDir = "www"; // directory for content files // For each file in the directory, create an S3 object stored in `siteBucket` -for (let item of fs.readdirSync(siteDir)) { - let filePath = require("path").join(siteDir, item); - let object = new aws.s3.BucketObject(item, { +for (const item of fs.readdirSync(siteDir)) { + const filePath = require("path").join(siteDir, item); + const object = new aws.s3.BucketObject(item, { bucket: siteBucket, // reference the s3.Bucket object source: new pulumi.asset.FileAsset(filePath), // use FileAsset to point to a file - contentType: mime.getType(filePath) || undefined // set the MIME type of the file + contentType: mime.getType(filePath) || undefined, // set the MIME type of the file }); } @@ -33,17 +35,17 @@ function publicReadPolicyForBucket(bucketName) { Principal: "*", Action: ["s3:GetObject"], Resource: [ - `arn:aws:s3:::${bucketName}/*` // policy refers to bucket name explicitly - ] - } - ] + `arn:aws:s3:::${bucketName}/*`, // policy refers to bucket name explicitly + ], + }, + ], }); } // Set the access policy for the bucket so all objects are readable -let bucketPolicy = new aws.s3.BucketPolicy("bucketPolicy", { +const bucketPolicy = new aws.s3.BucketPolicy("bucketPolicy", { bucket: siteBucket.bucket, // refer to the bucket created earlier - policy: siteBucket.bucket.apply(publicReadPolicyForBucket) // use output property `siteBucket.bucket` + policy: siteBucket.bucket.apply(publicReadPolicyForBucket), // use output property `siteBucket.bucket` }); // Stack exports diff --git a/kubernetes-ts-s3-rollout/index.ts b/kubernetes-ts-s3-rollout/index.ts index 5d022ed8d..cb64bfbf9 100644 --- a/kubernetes-ts-s3-rollout/index.ts +++ b/kubernetes-ts-s3-rollout/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; import * as s3Helpers from "./s3Helpers"; import * as util from "./util"; @@ -5,7 +7,7 @@ import * as util from "./util"; // Generate S3 bucket; put the local file `default.conf` inside it. const nginxConfigBucket = new s3Helpers.FileBucket("nginx-configs", { files: ["default.conf"], - policy: s3Helpers.publicReadPolicy + policy: s3Helpers.publicReadPolicy, }); const bucketId = nginxConfigBucket.fileIdFromHashedContents("default.conf"); @@ -33,13 +35,13 @@ const nginx = new k8s.apps.v1beta1.Deployment("nginx", { { image: "nginx:1.13.6-alpine", name: "nginx", - volumeMounts: [nginxConfigMount] - } + volumeMounts: [nginxConfigMount], + }, ], - volumes: [nginxConfigVol] - } - } - } + volumes: [nginxConfigVol], + }, + }, + }, }); // Expose proxy to the public Internet. @@ -49,7 +51,7 @@ const frontend = new k8s.core.v1.Service("nginx", { type: "LoadBalancer", ports: [{ port: 80, targetPort: 80, protocol: "TCP" }], selector: nginx.spec.template.metadata.labels, - } + }, }); // Export the frontend IP. diff --git a/kubernetes-ts-s3-rollout/s3Helpers.ts b/kubernetes-ts-s3-rollout/s3Helpers.ts index 866ed57da..fd7b95d57 100644 --- a/kubernetes-ts-s3-rollout/s3Helpers.ts +++ b/kubernetes-ts-s3-rollout/s3Helpers.ts @@ -1,6 +1,7 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as crypto from "crypto"; import * as fs from "fs"; -import * as path from "path"; import * as mime from "mime"; import * as aws from "@pulumi/aws"; @@ -27,7 +28,7 @@ export class FileBucket { this.files[file] = new aws.s3.BucketObject(file, { bucket: this.bucket, source: new pulumi.asset.FileAsset(file), - contentType: mime.getType(file) || undefined + contentType: mime.getType(file) || undefined, }); } @@ -36,7 +37,7 @@ export class FileBucket { this.policy = new aws.s3.BucketPolicy(`bucketPolicy`, { bucket: this.bucket.bucket, // policy: this.bucket.bucket.apply(publicReadPolicyForBucket) - policy: opts.policy(this.bucket) + policy: opts.policy(this.bucket), }); } } @@ -72,10 +73,10 @@ export function publicReadPolicy(bucket: aws.s3.Bucket): pulumi.Output { Principal: "*", Action: ["s3:GetObject"], Resource: [ - `arn:aws:s3:::${bucketName}/*` // policy refers to bucket name explicitly - ] - } - ] - }) + `arn:aws:s3:::${bucketName}/*`, // policy refers to bucket name explicitly + ], + }, + ], + }), ); } diff --git a/kubernetes-ts-s3-rollout/util.ts b/kubernetes-ts-s3-rollout/util.ts index 25aa44092..273cf832b 100644 --- a/kubernetes-ts-s3-rollout/util.ts +++ b/kubernetes-ts-s3-rollout/util.ts @@ -1,5 +1,6 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; -import * as aws from "@pulumi/aws"; // Utility function that creates a container that `curl`s a URL, placing it in a file in some shared // volume, namely at `${mount.mountPath}/${fileName}`. For example, `mount.mountPath` might be the @@ -8,7 +9,7 @@ import * as aws from "@pulumi/aws"; export function curl( url: pulumi.Output, fileName: string, - mount: { name: pulumi.Input; mountPath: pulumi.Input } + mount: { name: pulumi.Input; mountPath: pulumi.Input }, ) { return { name: "curl", @@ -16,6 +17,6 @@ export function curl( args: pulumi .all([url, mount.mountPath]) .apply(([url, mountPath]) => ["-o", `${mountPath}/${fileName}`, "-sL", url]), - volumeMounts: [mount] + volumeMounts: [mount], }; } diff --git a/kubernetes-ts-sock-shop/index.ts b/kubernetes-ts-sock-shop/index.ts index 4108898eb..d498d9075 100644 --- a/kubernetes-ts-sock-shop/index.ts +++ b/kubernetes-ts-sock-shop/index.ts @@ -1,7 +1,7 @@ // Copyright 2016-2018, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; +import * as pulumi from "@pulumi/pulumi"; // Minikube does not implement services of type `LoadBalancer`; require the user to specify if we're // running on minikube, and if so, create only services of type ClusterIP. @@ -20,17 +20,17 @@ const cartsDb = new k8s.apps.v1beta1.Deployment("carts-db", { metadata: { name: "carts-db", labels: { - name: "carts-db" + name: "carts-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "carts-db" - } + name: "carts-db", + }, }, spec: { containers: [ @@ -40,74 +40,74 @@ const cartsDb = new k8s.apps.v1beta1.Deployment("carts-db", { ports: [ { name: "mongo", - containerPort: 27017 - } + containerPort: 27017, + }, ], securityContext: { capabilities: { drop: ["all"], - add: ["CHOWN", "SETGID", "SETUID"] + add: ["CHOWN", "SETGID", "SETUID"], }, - readOnlyRootFilesystem: true + readOnlyRootFilesystem: true, }, volumeMounts: [ { mountPath: "/tmp", - name: "tmp-volume" - } - ] - } + name: "tmp-volume", + }, + ], + }, ], volumes: [ { name: "tmp-volume", emptyDir: { - medium: "Memory" - } - } + medium: "Memory", + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const cartsDbService = new k8s.core.v1.Service("carts-db", { metadata: { name: "carts-db", labels: { - name: "carts-db" + name: "carts-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 27017, - targetPort: 27017 - } + targetPort: 27017, + }, ], - selector: cartsDb.spec.template.metadata.labels - } + selector: cartsDb.spec.template.metadata.labels, + }, }); const carts = new k8s.apps.v1beta1.Deployment("carts", { metadata: { name: "carts", labels: { - name: "carts" + name: "carts", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "carts" - } + name: "carts", + }, }, spec: { containers: [ @@ -116,70 +116,70 @@ const carts = new k8s.apps.v1beta1.Deployment("carts", { image: "weaveworksdemos/carts:0.4.8", ports: [ { - containerPort: 80 - } + containerPort: 80, + }, ], env: [ { name: "ZIPKIN", - value: "zipkin.jaeger.svc.cluster.local" + value: "zipkin.jaeger.svc.cluster.local", }, { name: "JAVA_OPTS", value: - "-Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom" - } + "-Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom", + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { drop: ["all"], - add: ["NET_BIND_SERVICE"] + add: ["NET_BIND_SERVICE"], }, - readOnlyRootFilesystem: true + readOnlyRootFilesystem: true, }, volumeMounts: [ { mountPath: "/tmp", - name: "tmp-volume" - } - ] - } + name: "tmp-volume", + }, + ], + }, ], volumes: [ { name: "tmp-volume", emptyDir: { - medium: "Memory" - } - } + medium: "Memory", + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const cartsService = new k8s.core.v1.Service("carts", { metadata: { name: "carts", labels: { - name: "carts" + name: "carts", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: carts.spec.template.metadata.labels - } + selector: carts.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -190,17 +190,17 @@ const catalogDb = new k8s.apps.v1beta1.Deployment("catalog-db", { metadata: { name: "catalogue-db", labels: { - name: "catalogue-db" + name: "catalogue-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "catalogue-db" - } + name: "catalogue-db", + }, }, spec: { containers: [ @@ -210,63 +210,63 @@ const catalogDb = new k8s.apps.v1beta1.Deployment("catalog-db", { env: [ { name: "MYSQL_ROOT_PASSWORD", - value: "fake_password" + value: "fake_password", }, { name: "MYSQL_DATABASE", - value: "socksdb" - } + value: "socksdb", + }, ], ports: [ { name: "mysql", - containerPort: 3306 - } - ] - } + containerPort: 3306, + }, + ], + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const catalogDbService = new k8s.core.v1.Service("catalog-db", { metadata: { name: "catalogue-db", labels: { - name: "catalogue-db" + name: "catalogue-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 3306, - targetPort: 3306 - } + targetPort: 3306, + }, ], - selector: catalogDb.spec.template.metadata.labels - } + selector: catalogDb.spec.template.metadata.labels, + }, }); const catalog = new k8s.apps.v1beta1.Deployment("catalog", { metadata: { name: "catalogue", labels: { - name: "catalogue" + name: "catalogue", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "catalogue" - } + name: "catalogue", + }, }, spec: { containers: [ @@ -275,45 +275,45 @@ const catalog = new k8s.apps.v1beta1.Deployment("catalog", { image: "weaveworksdemos/catalogue:0.3.5", ports: [ { - containerPort: 80 - } + containerPort: 80, + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { drop: ["all"], - add: ["NET_BIND_SERVICE"] + add: ["NET_BIND_SERVICE"], }, - readOnlyRootFilesystem: true - } - } + readOnlyRootFilesystem: true, + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const catalogService = new k8s.core.v1.Service("catalog", { metadata: { name: "catalogue", labels: { - name: "catalogue" + name: "catalogue", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: catalog.spec.template.metadata.labels - } + selector: catalog.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -323,15 +323,15 @@ const catalogService = new k8s.core.v1.Service("catalog", { const frontend = new k8s.apps.v1beta1.Deployment("front-end", { metadata: { name: "front-end", - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "front-end" - } + name: "front-end", + }, }, spec: { containers: [ @@ -341,39 +341,39 @@ const frontend = new k8s.apps.v1beta1.Deployment("front-end", { resources: { requests: { cpu: "100m", - memory: "100Mi" - } + memory: "100Mi", + }, }, ports: [ { - containerPort: 8079 - } + containerPort: 8079, + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { - drop: ["all"] + drop: ["all"], }, - readOnlyRootFilesystem: true - } - } + readOnlyRootFilesystem: true, + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const frontendService = new k8s.core.v1.Service("front-end", { metadata: { name: "front-end", labels: { - name: "front-end" + name: "front-end", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { type: "NodePort", @@ -381,11 +381,11 @@ const frontendService = new k8s.core.v1.Service("front-end", { { port: 80, targetPort: 8079, - nodePort: 30001 - } + nodePort: 30001, + }, ], - selector: frontend.spec.template.metadata.labels - } + selector: frontend.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -396,17 +396,17 @@ const ordersDb = new k8s.apps.v1beta1.Deployment("orders-db", { metadata: { name: "orders-db", labels: { - name: "orders-db" + name: "orders-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "orders-db" - } + name: "orders-db", + }, }, spec: { containers: [ @@ -416,74 +416,74 @@ const ordersDb = new k8s.apps.v1beta1.Deployment("orders-db", { ports: [ { name: "mongo", - containerPort: 27017 - } + containerPort: 27017, + }, ], securityContext: { capabilities: { drop: ["all"], - add: ["CHOWN", "SETGID", "SETUID"] + add: ["CHOWN", "SETGID", "SETUID"], }, - readOnlyRootFilesystem: true + readOnlyRootFilesystem: true, }, volumeMounts: [ { mountPath: "/tmp", - name: "tmp-volume" - } - ] - } + name: "tmp-volume", + }, + ], + }, ], volumes: [ { name: "tmp-volume", emptyDir: { - medium: "Memory" - } - } + medium: "Memory", + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const ordersDbService = new k8s.core.v1.Service("orders-db", { metadata: { name: "orders-db", labels: { - name: "orders-db" + name: "orders-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 27017, - targetPort: 27017 - } + targetPort: 27017, + }, ], - selector: ordersDb.spec.template.metadata.labels - } + selector: ordersDb.spec.template.metadata.labels, + }, }); const orders = new k8s.apps.v1beta1.Deployment("orders", { metadata: { name: "orders", labels: { - name: "orders" + name: "orders", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "orders" - } + name: "orders", + }, }, spec: { containers: [ @@ -493,69 +493,69 @@ const orders = new k8s.apps.v1beta1.Deployment("orders", { env: [ { name: "ZIPKIN", - value: "zipkin.jaeger.svc.cluster.local" + value: "zipkin.jaeger.svc.cluster.local", }, { name: "JAVA_OPTS", value: - "-Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom" - } + "-Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom", + }, ], ports: [ { - containerPort: 80 - } + containerPort: 80, + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { drop: ["all"], - add: ["NET_BIND_SERVICE"] + add: ["NET_BIND_SERVICE"], }, - readOnlyRootFilesystem: true + readOnlyRootFilesystem: true, }, volumeMounts: [ { mountPath: "/tmp", - name: "tmp-volume" - } - ] - } + name: "tmp-volume", + }, + ], + }, ], volumes: [ { name: "tmp-volume", emptyDir: { - medium: "Memory" - } - } + medium: "Memory", + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const ordersService = new k8s.core.v1.Service("orders", { metadata: { name: "orders", labels: { - name: "orders" + name: "orders", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: orders.spec.template.metadata.labels - } + selector: orders.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -566,17 +566,17 @@ const payment = new k8s.apps.v1beta1.Deployment("payment", { metadata: { name: "payment", labels: { - name: "payment" + name: "payment", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "payment" - } + name: "payment", + }, }, spec: { containers: [ @@ -585,45 +585,45 @@ const payment = new k8s.apps.v1beta1.Deployment("payment", { image: "weaveworksdemos/payment:0.4.3", ports: [ { - containerPort: 80 - } + containerPort: 80, + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { drop: ["all"], - add: ["NET_BIND_SERVICE"] + add: ["NET_BIND_SERVICE"], }, - readOnlyRootFilesystem: true - } - } + readOnlyRootFilesystem: true, + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const paymentService = new k8s.core.v1.Service("payment", { metadata: { name: "payment", labels: { - name: "payment" + name: "payment", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: payment.spec.template.metadata.labels - } + selector: payment.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -634,17 +634,17 @@ const queueMaster = new k8s.apps.v1beta1.Deployment("queue-master", { metadata: { name: "queue-master", labels: { - name: "queue-master" + name: "queue-master", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "queue-master" - } + name: "queue-master", + }, }, spec: { containers: [ @@ -653,56 +653,56 @@ const queueMaster = new k8s.apps.v1beta1.Deployment("queue-master", { image: "weaveworksdemos/queue-master:0.3.1", ports: [ { - containerPort: 80 - } - ] - } + containerPort: 80, + }, + ], + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const queueMasterService = new k8s.core.v1.Service("queue-master", { metadata: { name: "queue-master", labels: { - name: "queue-master" + name: "queue-master", }, annotations: { - "prometheus.io/path": "/prometheus" + "prometheus.io/path": "/prometheus", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: queueMaster.spec.template.metadata.labels - } + selector: queueMaster.spec.template.metadata.labels, + }, }); const rabbitmq = new k8s.apps.v1beta1.Deployment("rabbitmq", { metadata: { name: "rabbitmq", labels: { - name: "rabbitmq" + name: "rabbitmq", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "rabbitmq" - } + name: "rabbitmq", + }, }, spec: { containers: [ @@ -711,43 +711,43 @@ const rabbitmq = new k8s.apps.v1beta1.Deployment("rabbitmq", { image: "rabbitmq:3.6.8", ports: [ { - containerPort: 5672 - } + containerPort: 5672, + }, ], securityContext: { capabilities: { drop: ["all"], - add: ["CHOWN", "SETGID", "SETUID", "DAC_OVERRIDE"] + add: ["CHOWN", "SETGID", "SETUID", "DAC_OVERRIDE"], }, - readOnlyRootFilesystem: true - } - } + readOnlyRootFilesystem: true, + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const rabbitmqService = new k8s.core.v1.Service("rabbitmq", { metadata: { name: "rabbitmq", labels: { - name: "rabbitmq" + name: "rabbitmq", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 5672, - targetPort: 5672 - } + targetPort: 5672, + }, ], - selector: rabbitmq.spec.template.metadata.labels - } + selector: rabbitmq.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -758,17 +758,17 @@ const shipping = new k8s.apps.v1beta1.Deployment("shipping", { metadata: { name: "shipping", labels: { - name: "shipping" + name: "shipping", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "shipping" - } + name: "shipping", + }, }, spec: { containers: [ @@ -778,69 +778,69 @@ const shipping = new k8s.apps.v1beta1.Deployment("shipping", { env: [ { name: "ZIPKIN", - value: "zipkin.jaeger.svc.cluster.local" + value: "zipkin.jaeger.svc.cluster.local", }, { name: "JAVA_OPTS", value: - "-Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom" - } + "-Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom", + }, ], ports: [ { - containerPort: 80 - } + containerPort: 80, + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { drop: ["all"], - add: ["NET_BIND_SERVICE"] + add: ["NET_BIND_SERVICE"], }, - readOnlyRootFilesystem: true + readOnlyRootFilesystem: true, }, volumeMounts: [ { mountPath: "/tmp", - name: "tmp-volume" - } - ] - } + name: "tmp-volume", + }, + ], + }, ], volumes: [ { name: "tmp-volume", emptyDir: { - medium: "Memory" - } - } + medium: "Memory", + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const shippingService = new k8s.core.v1.Service("shipping", { metadata: { name: "shipping", labels: { - name: "shipping" + name: "shipping", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: shipping.spec.template.metadata.labels - } + selector: shipping.spec.template.metadata.labels, + }, }); // -------------------------------------------------------------------------- @@ -851,17 +851,17 @@ const userDb = new k8s.apps.v1beta1.Deployment("user-db", { metadata: { name: "user-db", labels: { - name: "user-db" + name: "user-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "user-db" - } + name: "user-db", + }, }, spec: { containers: [ @@ -871,74 +871,74 @@ const userDb = new k8s.apps.v1beta1.Deployment("user-db", { ports: [ { name: "mongo", - containerPort: 27017 - } + containerPort: 27017, + }, ], securityContext: { capabilities: { drop: ["all"], - add: ["CHOWN", "SETGID", "SETUID"] + add: ["CHOWN", "SETGID", "SETUID"], }, - readOnlyRootFilesystem: true + readOnlyRootFilesystem: true, }, volumeMounts: [ { mountPath: "/tmp", - name: "tmp-volume" - } - ] - } + name: "tmp-volume", + }, + ], + }, ], volumes: [ { name: "tmp-volume", emptyDir: { - medium: "Memory" - } - } + medium: "Memory", + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const userDbService = new k8s.core.v1.Service("user-db", { metadata: { name: "user-db", labels: { - name: "user-db" + name: "user-db", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 27017, - targetPort: 27017 - } + targetPort: 27017, + }, ], - selector: userDb.spec.template.metadata.labels - } + selector: userDb.spec.template.metadata.labels, + }, }); const user = new k8s.apps.v1beta1.Deployment("user", { metadata: { name: "user", labels: { - name: "user" + name: "user", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { replicas: 1, template: { metadata: { labels: { - name: "user" - } + name: "user", + }, }, spec: { containers: [ @@ -947,49 +947,49 @@ const user = new k8s.apps.v1beta1.Deployment("user", { image: "weaveworksdemos/user:0.4.7", ports: [ { - containerPort: 80 - } + containerPort: 80, + }, ], env: [ { name: "MONGO_HOST", - value: "user-db:27017" - } + value: "user-db:27017", + }, ], securityContext: { runAsNonRoot: true, runAsUser: 10001, capabilities: { drop: ["all"], - add: ["NET_BIND_SERVICE"] + add: ["NET_BIND_SERVICE"], }, - readOnlyRootFilesystem: true - } - } + readOnlyRootFilesystem: true, + }, + }, ], nodeSelector: { - "beta.kubernetes.io/os": "linux" - } - } - } - } + "beta.kubernetes.io/os": "linux", + }, + }, + }, + }, }); const userService = new k8s.core.v1.Service("user", { metadata: { name: "user", labels: { - name: "user" + name: "user", }, - namespace: sockShopNs.metadata.name + namespace: sockShopNs.metadata.name, }, spec: { ports: [ { port: 80, - targetPort: 80 - } + targetPort: 80, + }, ], - selector: user.spec.template.metadata.labels - } + selector: user.spec.template.metadata.labels, + }, }); diff --git a/kubernetes-ts-staged-rollout-with-prometheus/index.ts b/kubernetes-ts-staged-rollout-with-prometheus/index.ts index 42b706f01..daa4a6c46 100644 --- a/kubernetes-ts-staged-rollout-with-prometheus/index.ts +++ b/kubernetes-ts-staged-rollout-with-prometheus/index.ts @@ -1,4 +1,5 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as k8s from "@pulumi/kubernetes"; import * as util from "./util"; @@ -6,7 +7,7 @@ import * as util from "./util"; const prometheus = new k8s.helm.v2.Chart("p8s", { repo: "stable", chart: "prometheus", - version: "6.10.0" + version: "6.10.0", }); const containerName = "example-app"; @@ -20,30 +21,30 @@ const instrumentedPod = { name: containerName, // Prometheus-instrumented app that generates artificial load on itself. image: "fabxc/instrumented_app", - ports: [{ name: "web", containerPort: 8080 }] - } - ] - } + ports: [{ name: "web", containerPort: 8080 }], + }, + ], + }, }; const p8sService = prometheus.getResource("v1/Service", "p8s-prometheus-server"); const p8sDeployment = prometheus.getResource( "extensions/v1beta1/Deployment", - "p8s-prometheus-server" + "p8s-prometheus-server", ); // IMPORTANT: This forwards the Prometheus service to localhost, so we can check it. If you are // running in-cluster, you probably don't need this! const localPort = 9090; const forwarderHandle = util.forwardPrometheusService(p8sService, p8sDeployment, { - localPort: localPort + localPort, }); // Canary ring. Replicate instrumented Pod 3 times. const canary = new k8s.apps.v1beta1.Deployment( "canary-example-app", { spec: { replicas: 1, template: instrumentedPod } }, - { dependsOn: p8sDeployment } + { dependsOn: p8sDeployment }, ); // Staging ring. Replicate instrumented Pod 10 times. @@ -58,11 +59,11 @@ const staging = new k8s.apps.v1beta1.Deployment("staging-example-app", { quantile: 0.9, thresholdMicroseconds: 100000, prometheusEndpoint: `localhost:${localPort}`, - forwarderHandle: forwarderHandle - }) - } + forwarderHandle, + }), + }, }, - spec: { replicas: 1, template: instrumentedPod } + spec: { replicas: 1, template: instrumentedPod }, }); export const p90ResponseTime = staging.metadata.annotations["example.com/p90ResponseTime"]; diff --git a/kubernetes-ts-staged-rollout-with-prometheus/util.ts b/kubernetes-ts-staged-rollout-with-prometheus/util.ts index b653d278f..0db92bafe 100644 --- a/kubernetes-ts-staged-rollout-with-prometheus/util.ts +++ b/kubernetes-ts-staged-rollout-with-prometheus/util.ts @@ -1,10 +1,10 @@ -import * as process from "child_process"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. -import * as pulumi from "@pulumi/pulumi"; import * as k8s from "@pulumi/kubernetes"; -import * as http from "http"; +import * as pulumi from "@pulumi/pulumi"; + import { spawn } from "child_process"; -import { meta } from "@pulumi/kubernetes/types/input"; +import * as http from "http"; export interface PromPortForwardOpts { localPort: number; @@ -22,10 +22,10 @@ export interface PromPortForwardOpts { export function forwardPrometheusService( service: pulumi.Input, deployment: pulumi.Input, - opts: PromPortForwardOpts + opts: PromPortForwardOpts, ): pulumi.Output<() => void> { if (pulumi.runtime.isDryRun()) { - return pulumi.output(() => {}); + return pulumi.output(() => undefined); } return pulumi.all([service, deployment]).apply(([s, d]) => pulumi.all([s.metadata, d.urn])).apply(([meta]) => { @@ -33,7 +33,7 @@ export function forwardPrometheusService( const forwarderHandle = spawn("kubectl", [ "port-forward", `service/${meta.name}`, - `${opts.localPort}:${opts.targetPort || 80}` + `${opts.localPort}:${opts.targetPort || 80}`, ]); // NOTE: we need to wrap `forwarderHandle.kill` because of JavaScript's `this` @@ -68,7 +68,7 @@ export interface CheckLatencyOpts { export function checkHttpLatency( canary: k8s.apps.v1beta1.Deployment, containerName: string, - opts: CheckLatencyOpts + opts: CheckLatencyOpts, ): pulumi.Output { if (pulumi.runtime.isDryRun()) { return pulumi.output(Promise.resolve("")); @@ -82,7 +82,7 @@ export function checkHttpLatency( // Turn an `http.get` into a `Promise`. // - const kill = opts.forwarderHandle || (() => {}); + const kill = opts.forwarderHandle || (() => undefined); return pulumi.all([canary.urn, kill]).apply(([_, kill]) => { console.log("Checking HTTP metrics"); @@ -100,7 +100,6 @@ function pollP8s(url: string, opts: CheckLatencyOpts): Promise { setTimeout(_ => { timedOut = true; }, opts.durationSeconds * 1000); - let count = 1; function pollRecursive(): Promise { return getHttpLatency(url).then(bodyText => { @@ -113,12 +112,12 @@ function pollP8s(url: string, opts: CheckLatencyOpts): Promise { return new Promise(resolve => setTimeout(_ => { resolve(microseconds); - }, (opts.periodSeconds || 1) * 1000) + }, (opts.periodSeconds || 1) * 1000), ).then(pollRecursive); }; const body = JSON.parse(bodyText); - if (body.data.result.length == 0) { + if (body.data.result.length === 0) { if (timedOut) { throw new Error(`Failed metrics check: no HTTP latency measurements returned`); } @@ -131,11 +130,11 @@ function pollP8s(url: string, opts: CheckLatencyOpts): Promise { // Check HTTP latency metrics. Recursively poll if the metrics have not met the // unacceptable latency threshold. - if (quantile == opts.quantile) { - if (microseconds == "" || microseconds == "NaN") { + if (quantile === opts.quantile) { + if (microseconds === "" || microseconds === "NaN") { if (timedOut) { throw new Error( - `Failed metrics check: querying HTTP latency got '${microseconds}'` + `Failed metrics check: querying HTTP latency got '${microseconds}'`, ); } // Ignore invalid data. @@ -144,10 +143,10 @@ function pollP8s(url: string, opts: CheckLatencyOpts): Promise { if (parseFloat(microseconds) > opts.thresholdMicroseconds) { console.error( - `Failed metrics check: required < ${opts.thresholdMicroseconds.toString()} microseconds, got '${microseconds}'` + `Failed metrics check: required < ${opts.thresholdMicroseconds.toString()} microseconds, got '${microseconds}'`, ); throw new Error( - `Failed metrics check: required < ${opts.thresholdMicroseconds.toString()} microseconds, got '${microseconds}'` + `Failed metrics check: required < ${opts.thresholdMicroseconds.toString()} microseconds, got '${microseconds}'`, ); } @@ -158,7 +157,7 @@ function pollP8s(url: string, opts: CheckLatencyOpts): Promise { } } throw new Error( - `Failed metrics check: required < 20000 microseconds, got '${microseconds}'` + `Failed metrics check: required < 20000 microseconds, got '${microseconds}'`, ); }); } diff --git a/linode-js-webserver/index.ts b/linode-js-webserver/index.ts index 4fc9abbd9..ce10b391a 100644 --- a/linode-js-webserver/index.ts +++ b/linode-js-webserver/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + const pulumi = require("@pulumi/pulumi"); const linode = require("@pulumi/linode"); const debian9 = "linode/debian9"; diff --git a/multicloud-ts-buckets/index.ts b/multicloud-ts-buckets/index.ts index 38a0fb420..81ea4856f 100644 --- a/multicloud-ts-buckets/index.ts +++ b/multicloud-ts-buckets/index.ts @@ -1,3 +1,5 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as aws from "@pulumi/aws"; import * as gcp from "@pulumi/gcp"; diff --git a/tslint.json b/tslint.json new file mode 100644 index 000000000..cb856b007 --- /dev/null +++ b/tslint.json @@ -0,0 +1,124 @@ +{ + "rules": { + "align": [ + true, + "parameters", + "statements" + ], + "ban": false, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "file-header": [ + true, + "Copyright \\d{4}-\\d{4}, Pulumi Corporation." + ], + "forin": true, + "indent": [ + true, + "spaces" + ], + "interface-name": false, + "jsdoc-format": false, + "label-position": true, + "member-access": false, + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-any": false, + "no-arg": true, + "no-bitwise": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": true, + "no-eval": true, + "no-inferrable-types": false, + "no-internal-module": true, + "no-parameter-properties": false, + "no-require-imports": false, + "no-shadowed-variable": false, + "no-string-literal": false, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-use-before-declare": false, + "no-var-keyword": true, + "no-var-requires": false, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "ordered-imports": true, + "prefer-const": true, + "quotemark": [ + true, + "double", + "avoid-escape" + ], + "radix": true, + "semicolon": true, + "switch-default": true, + "trailing-comma": [ + true, + { + "multiline": "always", + "singleline": "never" + } + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef": [ + false, + "call-signature", + "parameter", + "property-declaration", + "variable-declaration", + "member-variable-declaration" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "ban-keywords" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-module", + "check-separator", + "check-type" + ] + } +} diff --git a/twilio-ts-component/index.ts b/twilio-ts-component/index.ts index 613095761..810cc66e9 100644 --- a/twilio-ts-component/index.ts +++ b/twilio-ts-component/index.ts @@ -1,20 +1,22 @@ +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as pulumi from "@pulumi/pulumi"; -import * as twilo from "./twilio" +import * as twilo from "./twilio"; const config = new pulumi.Config(); const phoneNumberSid = config.require("phoneNumberSid"); const handler = new twilo.IncomingPhoneNumber("twilio-example", { phoneNumberSid: phoneNumberSid, - handler: async (p) => { + handler: async p => { return { statusCode: 200, headers: { - "Content-Type": "text/plain" + "Content-Type": "text/plain", }, - body: `Made with \u2764 and Pulumi.` - } - } + body: `Made with \u2764 and Pulumi.`, + }; + }, }); // We export the SMS URL, for debugging, you can post messages to it with curl to test out your handler without @@ -23,5 +25,5 @@ const handler = new twilo.IncomingPhoneNumber("twilio-example", { // $ curl -X POST -d "From=+12065555555" -d "Body=Hello!" $(pulumi stack output smsUrl) // // There are many additional properties you can provide which will be decoded and presented to your handler, -// see: https://www.twilio.com/docs/sms/twiml#request-parameters -export let smsUrl = handler.smsUrl; \ No newline at end of file +// see: https://www.twilio.com/docs/sms/twiml#request-parameters +export const smsUrl = handler.smsUrl; diff --git a/twilio-ts-component/twilio.ts b/twilio-ts-component/twilio.ts index 3202c28f2..e9f2bfdd9 100644 --- a/twilio-ts-component/twilio.ts +++ b/twilio-ts-component/twilio.ts @@ -1,8 +1,9 @@ -import * as pulumi from "@pulumi/pulumi"; +// Copyright 2016-2019, Pulumi Corporation. All rights reserved. + import * as serverless from "@pulumi/aws-serverless"; -import * as url from "url"; -import { Callback } from "@pulumi/aws-serverless/function"; import { APIArgs } from "@pulumi/aws-serverless/api"; +import { Callback } from "@pulumi/aws-serverless/function"; +import * as pulumi from "@pulumi/pulumi"; const config = new pulumi.Config("twilio"); const accountSid = config.require("accountSid"); @@ -11,10 +12,10 @@ const authToken = config.require("authToken"); export class IncomingPhoneNumber extends pulumi.ComponentResource { public /*out*/ readonly smsUrl: pulumi.Output; - constructor(name: string, args: IncomingPhoneNumberArgs, opts? : pulumi.ResourceOptions) { + constructor(name: string, args: IncomingPhoneNumberArgs, opts?: pulumi.ResourceOptions) { super("twilio:rest:IncomingPhoneNumber", name, {}, opts); - const apiArgs : APIArgs = { + const apiArgs: APIArgs = { routes: [{ path: "/sms", method: "POST", @@ -25,12 +26,12 @@ export class IncomingPhoneNumber extends pulumi.ComponentResource { const params = qs.parse(e.isBase64Encoded ? Buffer.from(e.body, "base64").toString() : e.body); // Loop over any provided media and add it to our array. - const allMedia: MediaInfo[] = [] + const allMedia: MediaInfo[] = []; for (let i = 0; i < params.NumMedia; i++) { allMedia.push({ ContentType: params[`MediaContentType${i}`], - Url: params[`MediaContentUrl${i}`] - }) + Url: params[`MediaContentUrl${i}`], + }); } // Copy the payload of the request into our representation. @@ -53,64 +54,64 @@ export class IncomingPhoneNumber extends pulumi.ComponentResource { State: params.ToState, Zip: params.ToZip, Country: params.ToCountry, - } - } + }, + }; // Delegate to the user provided handler. return args.handler(payload, ctx, cb); - } - }] + }, + }], }; const api = new serverless.apigateway.API(`${name}-api`, apiArgs, { parent: this }); this.smsUrl = pulumi.interpolate `${api.url}sms`; // Use the twilio SDK to update the handler for the SMS webhook to what we just created. - const twilio = require("twilio") + const twilio = require("twilio"); const client = new twilio(accountSid, authToken); - this.smsUrl.apply(url =>{ + this.smsUrl.apply(url => { client.incomingPhoneNumbers(args.phoneNumberSid).update({ smsMethod: "POST", - smsUrl: `${url}` + smsUrl: `${url}`, }).done(); }); // Register the smsUrl as an output of the component itself. super.registerOutputs({ - smsUrl: this.smsUrl + smsUrl: this.smsUrl, }); } } export interface IncomingPhoneNumberArgs { - phoneNumberSid: string, - handler: Callback + phoneNumberSid: string; + handler: Callback; } // See https://www.twilio.com/docs/sms/twiml#request-parameters for more information about // what each parameter means. export interface SmsPayload { - MessageSid: string, - AcountSid: string, - MessagingServiceSid: string, - From: string, - To: string, - Body: string, + MessageSid: string; + AcountSid: string; + MessagingServiceSid: string; + From: string; + To: string; + Body: string; Media: MediaInfo[]; - FromLocation: Location, - ToLocation: Location, + FromLocation: Location; + ToLocation: Location; } // Twilio attempts to look up this information and provide it, but it may not always be present. export interface Location { - City?: string, - State?: string, - Zip?: string, - Country?: string, + City?: string; + State?: string; + Zip?: string; + Country?: string; } export interface MediaInfo { - ContentType: string, - Url: string, -} \ No newline at end of file + ContentType: string; + Url: string; +}