@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
149 lines • 6.06 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.Authorizer = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an API Gateway Authorizer.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const demoRestApi = new aws.apigateway.RestApi("demo", {name: "auth-demo"});
* const invocationAssumeRole = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: ["apigateway.amazonaws.com"],
* }],
* actions: ["sts:AssumeRole"],
* }],
* });
* const invocationRole = new aws.iam.Role("invocation_role", {
* name: "api_gateway_auth_invocation",
* path: "/",
* assumeRolePolicy: invocationAssumeRole.then(invocationAssumeRole => invocationAssumeRole.json),
* });
* const lambdaAssumeRole = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* actions: ["sts:AssumeRole"],
* principals: [{
* type: "Service",
* identifiers: ["lambda.amazonaws.com"],
* }],
* }],
* });
* const lambda = new aws.iam.Role("lambda", {
* name: "demo-lambda",
* assumeRolePolicy: lambdaAssumeRole.then(lambdaAssumeRole => lambdaAssumeRole.json),
* });
* const authorizer = new aws.lambda.Function("authorizer", {
* code: new pulumi.asset.FileArchive("lambda-function.zip"),
* name: "api_gateway_authorizer",
* role: lambda.arn,
* handler: "exports.example",
* sourceCodeHash: std.filebase64sha256({
* input: "lambda-function.zip",
* }).then(invoke => invoke.result),
* });
* const demo = new aws.apigateway.Authorizer("demo", {
* name: "demo",
* restApi: demoRestApi.id,
* authorizerUri: authorizer.invokeArn,
* authorizerCredentials: invocationRole.arn,
* });
* const invocationPolicy = aws.iam.getPolicyDocumentOutput({
* statements: [{
* effect: "Allow",
* actions: ["lambda:InvokeFunction"],
* resources: [authorizer.arn],
* }],
* });
* const invocationPolicyRolePolicy = new aws.iam.RolePolicy("invocation_policy", {
* name: "default",
* role: invocationRole.id,
* policy: invocationPolicy.apply(invocationPolicy => invocationPolicy.json),
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import AWS API Gateway Authorizer using the `REST-API-ID/AUTHORIZER-ID`. For example:
*
* ```sh
* $ pulumi import aws:apigateway/authorizer:Authorizer authorizer 12345abcde/example
* ```
*/
class Authorizer extends pulumi.CustomResource {
/**
* Get an existing Authorizer 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 Authorizer(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of Authorizer. 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'] === Authorizer.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["authorizerCredentials"] = state?.authorizerCredentials;
resourceInputs["authorizerResultTtlInSeconds"] = state?.authorizerResultTtlInSeconds;
resourceInputs["authorizerUri"] = state?.authorizerUri;
resourceInputs["identitySource"] = state?.identitySource;
resourceInputs["identityValidationExpression"] = state?.identityValidationExpression;
resourceInputs["name"] = state?.name;
resourceInputs["providerArns"] = state?.providerArns;
resourceInputs["region"] = state?.region;
resourceInputs["restApi"] = state?.restApi;
resourceInputs["type"] = state?.type;
}
else {
const args = argsOrState;
if (args?.restApi === undefined && !opts.urn) {
throw new Error("Missing required property 'restApi'");
}
resourceInputs["authorizerCredentials"] = args?.authorizerCredentials;
resourceInputs["authorizerResultTtlInSeconds"] = args?.authorizerResultTtlInSeconds;
resourceInputs["authorizerUri"] = args?.authorizerUri;
resourceInputs["identitySource"] = args?.identitySource;
resourceInputs["identityValidationExpression"] = args?.identityValidationExpression;
resourceInputs["name"] = args?.name;
resourceInputs["providerArns"] = args?.providerArns;
resourceInputs["region"] = args?.region;
resourceInputs["restApi"] = args?.restApi;
resourceInputs["type"] = args?.type;
resourceInputs["arn"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Authorizer.__pulumiType, name, resourceInputs, opts);
}
}
exports.Authorizer = Authorizer;
/** @internal */
Authorizer.__pulumiType = 'aws:apigateway/authorizer:Authorizer';
//# sourceMappingURL=authorizer.js.map