How to use the aws-sdk.APIGateway function in aws-sdk

To help you get started, we’ve selected a few aws-sdk 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 mjgillespie / swaggy-lambda / api-gateway.js View on Github external
var uuid = require('node-uuid');
var swagger = util.parseSwaggerFile('./swagger.json');
var lambda = new AWS.Lambda();

awsQ(AWS);

AWS.config.region = 'us-east-1';

AWS.config.apiVersions = {
    s3: '2006-03-01',
    apigateway: '2015-07-09'

    // other service API versions
};

var apigateway = new AWS.APIGateway();

module.exports = {
    initializeGateway: function(apiName, apiDescription) {
        var params = {
            name: apiName,
            description: apiDescription
        };
        return apigateway.createRestApi(params).promise();
    },

    deleteResources: function(restApiId) {
        return apigateway.getResources({
                restApiId: restApiId
            })
            .then(function(data) {
github laconiajs / laconia / packages / laconia-acceptance-test / acceptance-test / acceptance.spec.js View on Github external
const getOrderUrl = async () => {
  const apig = new AWS.APIGateway();
  const restApis = await apig.getRestApis().promise();
  const restApiName = `${SERVERLESS_STAGE}-${SERVERLESS_SERVICE_NAME}`;
  const restApi = restApis.items.find(i => i.name === restApiName);
  if (!restApi) {
    throw new Error(`${restApiName} could not be found!`);
  }
  return `https://${restApi.id}.execute-api.${AWS_REGION}.amazonaws.com/${SERVERLESS_STAGE}/order`;
};
github matthewkeil / nomad-devops / bin / aws / apiGateway.ts View on Github external
import AWS from "aws-sdk";
import { config } from "../../config";

const apiGateway = new AWS.APIGateway(config.AWS_SERVICE_CONFIG);
const iam = new AWS.IAM(config.AWS_SERVICE_CONFIG);

export const apiGatewayAccountExists = async () => {
    try {
        const { cloudwatchRoleArn } = await apiGateway.getAccount().promise();
        const RoleName = cloudwatchRoleArn.split("/")[1];
        await iam.getRole({ RoleName }).promise();
        return true;
    } catch (err) {
        if (err.code === "NoSuchEntity") return false;
    }
};
github claudiajs / claudia / spec / set-version-spec.js View on Github external
beforeEach(() => {
		workingdir = tmppath();
		testRunName = 'test' + Date.now();
		lambda = new aws.Lambda({region: awsRegion});
		apiGateway = retriableWrap(new aws.APIGateway({region: awsRegion}));
		newObjects = {workingdir: workingdir};
		fs.mkdirSync(workingdir);
	});
github YoruNoHikage / apex-api-gateway / src / index.js View on Github external
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const defaultsDeep = require('lodash.defaultsdeep');
const entries = require('lodash.topairs');
const yargs = require('yargs');
const AWS = require('aws-sdk');
const apigateway = new AWS.APIGateway();

const args = yargs
              .usage('Usage: $0  [options]')
              .alias('c', 'config')
              .nargs('c', 1)
              .describe('c', 'Apex project JSON file location')
              .command('create  [description] [cloneFrom]', 'Create a new REST API on AWS API Gateway', {
                force: { alias: 'f', describe: 'Force creating REST API overriding existing configuration' }
              }, create)
              .command('update', 'Update the REST API with the new Swagger definitions', {
                stdout: { describe: 'Output swagger to console without deploying' },
              }, update)
              .help()
              .argv;

function create({ name, description = null, cloneFrom = '', config = './project.json', force }) {
github webiny / webiny-js / components / serverless-aws-api-gateway / serverless.js View on Github external
async remove(inputs = {}) {
        this.context.status("Removing");

        const apig = new AWS.APIGateway({
            region: this.state.region || defaults.region,
            credentials: this.context.credentials.aws
        });

        if (this.state.id) {
            this.context.instance.debug(
                `API ID %o found in state. Removing from the %o.`,
                this.state.id,
                this.state.region
            );
            await retry(() => removeApi({ apig, apiId: this.state.id }));

            this.context.instance.debug(
                `API with ID %o was successfully removed from the %o region.`,
                this.state.id,
                this.state.region
github architect / architect / src / create / aws / create-slack-endpoints / _create-resource / _get-resources.js View on Github external
setTimeout(function _latency() {
    params = params || {}
    params.limit = 500
    let gateway = new aws.APIGateway({region: process.env.AWS_REGION})
    gateway.getResources(params, callback)
  }, 2016)
}
github claudiajs / claudia / spec / create-spec.js View on Github external
beforeAll(() => {
		iam = new aws.IAM({ region: awsRegion });
		lambda = new aws.Lambda({ region: awsRegion });
		s3 = new aws.S3({region: awsRegion, signatureVersion: 'v4'});
		apiGatewayPromise = retriableWrap(new aws.APIGateway({ region: awsRegion }));
		logs = new aws.CloudWatchLogs({ region: awsRegion });
		sns = new aws.SNS({region: awsRegion});
	});
	beforeEach(() => {
github claudiajs / claudia / spec / util / destroy-objects.js View on Github external
module.exports = function destroyObjects(newObjects) {
	'use strict';
	const lambda = new aws.Lambda({ region: awsRegion }),
		logs = new aws.CloudWatchLogs({ region: awsRegion }),
		apiGatewayPromise = retriableWrap(new aws.APIGateway({ region: awsRegion })),
		s3 = new aws.S3({ region: awsRegion }),
		iot = new aws.Iot({ region: awsRegion }),
		sns = new aws.SNS({ region: awsRegion }),
		sqs = new aws.SQS({ region: awsRegion }),
		iam = new aws.IAM({ region: awsRegion }),
		events = new aws.CloudWatchEvents({ region: awsRegion }),
		cognitoIdentityServiceProvider = new aws.CognitoIdentityServiceProvider({ region: awsRegion }),
		destroyRule = function (ruleName) {
			return events.listTargetsByRule({ Rule: ruleName }).promise()
			.then(config => {
				const ids = config.Targets.map(target => target.Id);
				if (ids.length) {
					return events.removeTargets({ Rule: ruleName, Ids: ids }).promise();
				}
			})
			.then(() => events.deleteRule({ Name: ruleName }).promise());