How to use the @pulumi/aws.apigateway function in @pulumi/aws

To help you get started, we’ve selected a few @pulumi/aws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pulumi / examples / aws-ts-serverless-raw / index.ts View on Github external
function swaggerRouteHandler(lambdaArn: string) {
    const region = aws.config.requireRegion();
    return {
        "x-amazon-apigateway-any-method": {
            "x-amazon-apigateway-integration": {
                uri: `arn:aws:apigateway:${region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations`,
                passthroughBehavior: "when_no_match",
                httpMethod: "POST",
                type: "aws_proxy",
            },
        },
    };
}

// Create the API Gateway Rest API, using a swagger spec.
const restApi = new aws.apigateway.RestApi("api", {
    body: lambda.arn.apply(lambdaArn => swaggerSpec(lambdaArn)),
});

// Create a deployment of the Rest API.
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.
const stage = new aws.apigateway.Stage("api-stage", {
    restApi: restApi,
    deployment: deployment,
    stageName: stageName,
});
github pulumi / pulumi-aws / examples / serverless-raw / index.ts View on Github external
//      info: { title: "myrestapi", version: "1.0" },
//      paths: {
//        "/bambam": {
//          "x-amazon-apigateway-any-method": {
//            "x-amazon-apigateway-integration": {
//              uri: ,
//              passthroughBehavior: "when_no_match",
//              httpMethod: "POST",
//              type: "aws_proxy",
//            },
//          },
//        },
//      },
//    };

let restApi = new aws.apigateway.RestApi("myrestapi", {});

let resource = new aws.apigateway.Resource("myrestapi-resource", {
    restApi: restApi,
    pathPart: "bambam",
    parentId: restApi.rootResourceId!,
});

let method = new aws.apigateway.Method("myrestapi-method", {
    restApi: restApi,
    resourceId: resource.id,
    httpMethod: "ANY",
    authorization: "NONE",
});

let integration = new aws.apigateway.Integration("myrestapi-integration", {
    restApi: restApi,
github pulumi / examples / aws-ts-serverless-raw / index.ts View on Github external
}

// Create the API Gateway Rest API, using a swagger spec.
const restApi = new aws.apigateway.RestApi("api", {
    body: lambda.arn.apply(lambdaArn => swaggerSpec(lambdaArn)),
});

// Create a deployment of the Rest API.
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.
const stage = new aws.apigateway.Stage("api-stage", {
    restApi: restApi,
    deployment: deployment,
    stageName: stageName,
});

// Give permissions from API Gateway to invoke the Lambda
const invokePermission = new aws.lambda.Permission("api-lambda-permission", {
    action: "lambda:invokeFunction",
    function: lambda,
    principal: "apigateway.amazonaws.com",
    sourceArn: pulumi.interpolate `${deployment.executionArn}*/*`,
});

// Export the https endpoint of the running Rest API
export let endpoint = pulumi.interpolate `${deployment.invokeUrl}${stageName}`;
github pulumi / pulumi-aws / examples / api / step2 / index.ts View on Github external
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as aws from "@pulumi/aws";

const api = new aws.apigateway.x.API("myapi", {
    routes: [{
        path: "/b",
        method: "GET",
        eventHandler: async (event) => {
            return {
                statusCode: 200,
                body: "<h1>Hello world!</h1>",
            };
        }
    }],
});

export const url = api.url;
github pulumi / pulumi-awsx / nodejs / awsx / elasticloadbalancingv2 / network.ts View on Github external
public target(name: string, parent: pulumi.Resource): pulumi.Input {
        // create a VpcLink to the load balancer in the VPC
        const vpcLink = new aws.apigateway.VpcLink(name, {
            targetArn: this.loadBalancer.loadBalancer.arn,
        }, { parent });

        return this.endpoint.apply(ep =&gt; ({
            uri: `http://${ep.hostname}:${ep.port}/`,
            connectionType: "VPC_LINK",
            connectionId: vpcLink.id,
        }));
    }
}
github pulumi / pulumi-aws / examples / api / index.ts View on Github external
};
const role = new aws.iam.Role("mylambda-role", {
    assumeRolePolicy: JSON.stringify(policy),
});
const fullAccess = new aws.iam.RolePolicyAttachment("mylambda-access", {
    role: role,
    policyArn: aws.iam.AWSLambdaFullAccess,
});
const lambda = new aws.lambda.Function("myfunction", {
    code: new pulumi.asset.FileArchive("./afunction"),
    role: role.arn,
    handler: "index.handler",
    runtime: aws.lambda.NodeJS8d10Runtime,
});

const api = new aws.apigateway.x.API("myapi", {
    routes: [{
        path: "/a",
        method: "GET",
        eventHandler: async (event) =&gt; {
            return {
                statusCode: 200,
                body: "<h1>Hello world!</h1>",
            };
        },
    }, {
        path: "/b",
        method: "GET",
        eventHandler: lambda,
    }, {
        path: "/www",
        localPath: "www"
github pulumi / pulumi-aws / examples / regression / 250.ts View on Github external
const aws = require("@pulumi/aws");
const apiKey = new aws.apigateway.ApiKey("key", {});
const usagePlan = new aws.apigateway.UsagePlan("plan", {});
exports.usagePlanKey = new aws.apigateway.UsagePlanKey('MyUsagePlanKey',{
    keyId: apiKey.id,
    keyType: 'API_KEY',
    usagePlanId: usagePlan.id
});
github pulumi / pulumi-aws / examples / serverless-raw / index.ts View on Github external
httpMethod: "ANY",
    authorization: "NONE",
});

let integration = new aws.apigateway.Integration("myrestapi-integration", {
    restApi: restApi,
    resourceId: resource.id,
    httpMethod: "ANY",
    type: "AWS_PROXY",
    integrationHttpMethod: "POST",
    passthroughBehavior: "WHEN_NO_MATCH",
    uri: lambda.arn.apply(arn =>
        arn && "arn:aws:apigateway:" + region + ":lambda:path/2015-03-31/functions/" + arn + "/invocations"),
}, { dependsOn: [ method ] });

let deployment = new aws.apigateway.Deployment("myrestapi-deployment-prod", {
    restApi: restApi,
    description: "my deployment",
    stageName: "prod",
}, { dependsOn: [ integration ] });
github pulumi / pulumi-aws / examples / regression / 250.ts View on Github external
const aws = require("@pulumi/aws");
const apiKey = new aws.apigateway.ApiKey("key", {});
const usagePlan = new aws.apigateway.UsagePlan("plan", {});
exports.usagePlanKey = new aws.apigateway.UsagePlanKey('MyUsagePlanKey',{
    keyId: apiKey.id,
    keyType: 'API_KEY',
    usagePlanId: usagePlan.id
});
github pulumi / pulumi-awsx / nodejs / examples / metrics / index.ts View on Github external
const topicAlarm = topicMetric.createAlarm("alarm" + alarmIndex++, { threshold: 1000, evaluationPeriods: 2 });

const queue = new aws.sqs.Queue("terraform_queue", {
    delaySeconds: 90,
    maxMessageSize: 2048,
    messageRetentionSeconds: 86400,
    receiveWaitTimeSeconds: 10,
    tags: {
        Environment: "production",
    },
});

const queueMetric = awsx.sqs.metrics.sentMessageSize({ queue });
const queueAlarm = queueMetric.createAlarm("alarm" + alarmIndex++, { threshold: 120, evaluationPeriods: 2 });

const restApi = new aws.apigateway.RestApi("MyDemoAPI", {
    description: "This is my API for demonstration purposes",
  });

const restApiMetric = awsx.apigateway.metrics.error5XX({ restApi });
const restApiAlarm = restApiMetric.createAlarm("alarm" + alarmIndex++, { threshold: 50, evaluationPeriods: 2 });

const table = new aws.dynamodb.Table("testtable", {
    attributes: [{
        name: "id",
        type: "S",
    }],
    hashKey: "id",
    readCapacity: 5,
    writeCapacity: 5,
    streamEnabled: true,
    streamViewType: "NEW_AND_OLD_IMAGES",