@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
152 lines • 6.21 kB
JavaScript
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Method = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides a HTTP Method for an API Gateway Resource.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const myDemoAPI = new aws.apigateway.RestApi("MyDemoAPI", {
* name: "MyDemoAPI",
* description: "This is my API for demonstration purposes",
* });
* const myDemoResource = new aws.apigateway.Resource("MyDemoResource", {
* restApi: myDemoAPI.id,
* parentId: myDemoAPI.rootResourceId,
* pathPart: "mydemoresource",
* });
* const myDemoMethod = new aws.apigateway.Method("MyDemoMethod", {
* restApi: myDemoAPI.id,
* resourceId: myDemoResource.id,
* httpMethod: "GET",
* authorization: "NONE",
* });
* ```
*
* ## Usage with Cognito User Pool Authorizer
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const config = new pulumi.Config();
* const cognitoUserPoolName = config.requireObject<any>("cognitoUserPoolName");
* const _this = aws.cognito.getUserPools({
* name: cognitoUserPoolName,
* });
* const thisRestApi = new aws.apigateway.RestApi("this", {name: "with-authorizer"});
* const thisResource = new aws.apigateway.Resource("this", {
* restApi: thisRestApi.id,
* parentId: thisRestApi.rootResourceId,
* pathPart: "{proxy+}",
* });
* const thisAuthorizer = new aws.apigateway.Authorizer("this", {
* name: "CognitoUserPoolAuthorizer",
* type: "COGNITO_USER_POOLS",
* restApi: thisRestApi.id,
* providerArns: _this.then(_this => _this.arns),
* });
* const any = new aws.apigateway.Method("any", {
* restApi: thisRestApi.id,
* resourceId: thisResource.id,
* httpMethod: "ANY",
* authorization: "COGNITO_USER_POOLS",
* authorizerId: thisAuthorizer.id,
* requestParameters: {
* "method.request.path.proxy": true,
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import `aws_api_gateway_method` using `REST-API-ID/RESOURCE-ID/HTTP-METHOD`. For example:
*
* ```sh
* $ pulumi import aws:apigateway/method:Method example 12345abcde/67890fghij/GET
* ```
*/
class Method extends pulumi.CustomResource {
/**
* Get an existing Method resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new Method(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Method. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === Method.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["apiKeyRequired"] = state?.apiKeyRequired;
resourceInputs["authorization"] = state?.authorization;
resourceInputs["authorizationScopes"] = state?.authorizationScopes;
resourceInputs["authorizerId"] = state?.authorizerId;
resourceInputs["httpMethod"] = state?.httpMethod;
resourceInputs["operationName"] = state?.operationName;
resourceInputs["region"] = state?.region;
resourceInputs["requestModels"] = state?.requestModels;
resourceInputs["requestParameters"] = state?.requestParameters;
resourceInputs["requestValidatorId"] = state?.requestValidatorId;
resourceInputs["resourceId"] = state?.resourceId;
resourceInputs["restApi"] = state?.restApi;
}
else {
const args = argsOrState;
if (args?.authorization === undefined && !opts.urn) {
throw new Error("Missing required property 'authorization'");
}
if (args?.httpMethod === undefined && !opts.urn) {
throw new Error("Missing required property 'httpMethod'");
}
if (args?.resourceId === undefined && !opts.urn) {
throw new Error("Missing required property 'resourceId'");
}
if (args?.restApi === undefined && !opts.urn) {
throw new Error("Missing required property 'restApi'");
}
resourceInputs["apiKeyRequired"] = args?.apiKeyRequired;
resourceInputs["authorization"] = args?.authorization;
resourceInputs["authorizationScopes"] = args?.authorizationScopes;
resourceInputs["authorizerId"] = args?.authorizerId;
resourceInputs["httpMethod"] = args?.httpMethod;
resourceInputs["operationName"] = args?.operationName;
resourceInputs["region"] = args?.region;
resourceInputs["requestModels"] = args?.requestModels;
resourceInputs["requestParameters"] = args?.requestParameters;
resourceInputs["requestValidatorId"] = args?.requestValidatorId;
resourceInputs["resourceId"] = args?.resourceId;
resourceInputs["restApi"] = args?.restApi;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Method.__pulumiType, name, resourceInputs, opts);
}
}
exports.Method = Method;
/** @internal */
Method.__pulumiType = 'aws:apigateway/method:Method';
//# sourceMappingURL=method.js.map
;