@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
369 lines • 18.1 kB
JavaScript
"use strict";
// *** 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.Listener = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides a Load Balancer Listener resource.
*
* > **Note:** `aws.alb.Listener` is known as `aws.lb.Listener`. The functionality is identical.
*
* ## Example Usage
*
* ### Forward Action
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.LoadBalancer("front_end", {});
* const frontEndTargetGroup = new aws.lb.TargetGroup("front_end", {});
* const frontEndListener = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEnd.arn,
* port: 443,
* protocol: "HTTPS",
* sslPolicy: "ELBSecurityPolicy-2016-08",
* certificateArn: "arn:aws:iam::187416307283:server-certificate/test_cert_rab3wuqwgja25ct3n4jdj2tzu4",
* defaultActions: [{
* type: "forward",
* targetGroupArn: frontEndTargetGroup.arn,
* }],
* });
* ```
*
* With weighted target groups:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.LoadBalancer("front_end", {});
* const frontEndBlue = new aws.lb.TargetGroup("front_end_blue", {});
* const frontEndGreen = new aws.lb.TargetGroup("front_end_green", {});
* const frontEndListener = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEnd.arn,
* port: 443,
* protocol: "HTTPS",
* sslPolicy: "ELBSecurityPolicy-2016-08",
* certificateArn: "arn:aws:iam::187416307283:server-certificate/test_cert_rab3wuqwgja25ct3n4jdj2tzu4",
* defaultActions: [{
* type: "forward",
* forward: {
* targetGroups: [
* {
* arn: frontEndBlue.arn,
* weight: 100,
* },
* {
* arn: frontEndGreen.arn,
* weight: 0,
* },
* ],
* },
* }],
* });
* ```
*
* To a NLB:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEndAwsLb.arn,
* port: 443,
* protocol: "TLS",
* sslPolicy: "ELBSecurityPolicy-2016-08",
* certificateArn: "arn:aws:iam::187416307283:server-certificate/test_cert_rab3wuqwgja25ct3n4jdj2tzu4",
* alpnPolicy: "HTTP2Preferred",
* defaultActions: [{
* type: "forward",
* targetGroupArn: frontEndAwsLbTargetGroup.arn,
* }],
* });
* ```
*
* ### Redirect Action
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.LoadBalancer("front_end", {});
* const frontEndListener = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEnd.arn,
* port: 80,
* protocol: "HTTP",
* defaultActions: [{
* type: "redirect",
* redirect: {
* port: "443",
* protocol: "HTTPS",
* statusCode: "HTTP_301",
* },
* }],
* });
* ```
*
* ### Fixed-response Action
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.LoadBalancer("front_end", {});
* const frontEndListener = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEnd.arn,
* port: 80,
* protocol: "HTTP",
* defaultActions: [{
* type: "fixed-response",
* fixedResponse: {
* contentType: "text/plain",
* messageBody: "Fixed response content",
* statusCode: "200",
* },
* }],
* });
* ```
*
* ### Authenticate-cognito Action
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.LoadBalancer("front_end", {});
* const frontEndTargetGroup = new aws.lb.TargetGroup("front_end", {});
* const pool = new aws.cognito.UserPool("pool", {});
* const client = new aws.cognito.UserPoolClient("client", {});
* const domain = new aws.cognito.UserPoolDomain("domain", {});
* const frontEndListener = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEnd.arn,
* port: 80,
* protocol: "HTTP",
* defaultActions: [
* {
* type: "authenticate-cognito",
* authenticateCognito: {
* userPoolArn: pool.arn,
* userPoolClientId: client.id,
* userPoolDomain: domain.domain,
* },
* },
* {
* type: "forward",
* targetGroupArn: frontEndTargetGroup.arn,
* },
* ],
* });
* ```
*
* ### Authenticate-OIDC Action
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const frontEnd = new aws.lb.LoadBalancer("front_end", {});
* const frontEndTargetGroup = new aws.lb.TargetGroup("front_end", {});
* const frontEndListener = new aws.lb.Listener("front_end", {
* loadBalancerArn: frontEnd.arn,
* port: 80,
* protocol: "HTTP",
* defaultActions: [
* {
* type: "authenticate-oidc",
* authenticateOidc: {
* authorizationEndpoint: "https://example.com/authorization_endpoint",
* clientId: "client_id",
* clientSecret: "client_secret",
* issuer: "https://example.com",
* tokenEndpoint: "https://example.com/token_endpoint",
* userInfoEndpoint: "https://example.com/user_info_endpoint",
* },
* },
* {
* type: "forward",
* targetGroupArn: frontEndTargetGroup.arn,
* },
* ],
* });
* ```
*
* ### Gateway Load Balancer Listener
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lb.LoadBalancer("example", {
* loadBalancerType: "gateway",
* name: "example",
* subnetMappings: [{
* subnetId: exampleAwsSubnet.id,
* }],
* });
* const exampleTargetGroup = new aws.lb.TargetGroup("example", {
* name: "example",
* port: 6081,
* protocol: "GENEVE",
* vpcId: exampleAwsVpc.id,
* healthCheck: {
* port: "80",
* protocol: "HTTP",
* },
* });
* const exampleListener = new aws.lb.Listener("example", {
* loadBalancerArn: example.id,
* defaultActions: [{
* targetGroupArn: exampleTargetGroup.id,
* type: "forward",
* }],
* });
* ```
*
* ### Mutual TLS Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.lb.LoadBalancer("example", {loadBalancerType: "application"});
* const exampleTargetGroup = new aws.lb.TargetGroup("example", {});
* const exampleListener = new aws.lb.Listener("example", {
* loadBalancerArn: example.id,
* defaultActions: [{
* targetGroupArn: exampleTargetGroup.id,
* type: "forward",
* }],
* mutualAuthentication: {
* mode: "verify",
* trustStoreArn: "...",
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import listeners using their ARN. For example:
*
* ```sh
* $ pulumi import aws:lb/listener:Listener front_end arn:aws:elasticloadbalancing:us-west-2:187416307283:listener/app/front-end-alb/8e4497da625e2d8a/9ab28ade35828f96
* ```
*/
class Listener extends pulumi.CustomResource {
/**
* Get an existing Listener 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 Listener(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Listener. 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'] === Listener.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["alpnPolicy"] = state ? state.alpnPolicy : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["certificateArn"] = state ? state.certificateArn : undefined;
resourceInputs["defaultActions"] = state ? state.defaultActions : undefined;
resourceInputs["loadBalancerArn"] = state ? state.loadBalancerArn : undefined;
resourceInputs["mutualAuthentication"] = state ? state.mutualAuthentication : undefined;
resourceInputs["port"] = state ? state.port : undefined;
resourceInputs["protocol"] = state ? state.protocol : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertHeaderName"] = state ? state.routingHttpRequestXAmznMtlsClientcertHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertIssuerHeaderName"] = state ? state.routingHttpRequestXAmznMtlsClientcertIssuerHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertLeafHeaderName"] = state ? state.routingHttpRequestXAmznMtlsClientcertLeafHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName"] = state ? state.routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertSubjectHeaderName"] = state ? state.routingHttpRequestXAmznMtlsClientcertSubjectHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertValidityHeaderName"] = state ? state.routingHttpRequestXAmznMtlsClientcertValidityHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznTlsCipherSuiteHeaderName"] = state ? state.routingHttpRequestXAmznTlsCipherSuiteHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznTlsVersionHeaderName"] = state ? state.routingHttpRequestXAmznTlsVersionHeaderName : undefined;
resourceInputs["routingHttpResponseAccessControlAllowCredentialsHeaderValue"] = state ? state.routingHttpResponseAccessControlAllowCredentialsHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlAllowHeadersHeaderValue"] = state ? state.routingHttpResponseAccessControlAllowHeadersHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlAllowMethodsHeaderValue"] = state ? state.routingHttpResponseAccessControlAllowMethodsHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlAllowOriginHeaderValue"] = state ? state.routingHttpResponseAccessControlAllowOriginHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlExposeHeadersHeaderValue"] = state ? state.routingHttpResponseAccessControlExposeHeadersHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlMaxAgeHeaderValue"] = state ? state.routingHttpResponseAccessControlMaxAgeHeaderValue : undefined;
resourceInputs["routingHttpResponseContentSecurityPolicyHeaderValue"] = state ? state.routingHttpResponseContentSecurityPolicyHeaderValue : undefined;
resourceInputs["routingHttpResponseServerEnabled"] = state ? state.routingHttpResponseServerEnabled : undefined;
resourceInputs["routingHttpResponseStrictTransportSecurityHeaderValue"] = state ? state.routingHttpResponseStrictTransportSecurityHeaderValue : undefined;
resourceInputs["routingHttpResponseXContentTypeOptionsHeaderValue"] = state ? state.routingHttpResponseXContentTypeOptionsHeaderValue : undefined;
resourceInputs["routingHttpResponseXFrameOptionsHeaderValue"] = state ? state.routingHttpResponseXFrameOptionsHeaderValue : undefined;
resourceInputs["sslPolicy"] = state ? state.sslPolicy : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
resourceInputs["tcpIdleTimeoutSeconds"] = state ? state.tcpIdleTimeoutSeconds : undefined;
}
else {
const args = argsOrState;
if ((!args || args.defaultActions === undefined) && !opts.urn) {
throw new Error("Missing required property 'defaultActions'");
}
if ((!args || args.loadBalancerArn === undefined) && !opts.urn) {
throw new Error("Missing required property 'loadBalancerArn'");
}
resourceInputs["alpnPolicy"] = args ? args.alpnPolicy : undefined;
resourceInputs["certificateArn"] = args ? args.certificateArn : undefined;
resourceInputs["defaultActions"] = args ? args.defaultActions : undefined;
resourceInputs["loadBalancerArn"] = args ? args.loadBalancerArn : undefined;
resourceInputs["mutualAuthentication"] = args ? args.mutualAuthentication : undefined;
resourceInputs["port"] = args ? args.port : undefined;
resourceInputs["protocol"] = args ? args.protocol : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertHeaderName"] = args ? args.routingHttpRequestXAmznMtlsClientcertHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertIssuerHeaderName"] = args ? args.routingHttpRequestXAmznMtlsClientcertIssuerHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertLeafHeaderName"] = args ? args.routingHttpRequestXAmznMtlsClientcertLeafHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName"] = args ? args.routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertSubjectHeaderName"] = args ? args.routingHttpRequestXAmznMtlsClientcertSubjectHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznMtlsClientcertValidityHeaderName"] = args ? args.routingHttpRequestXAmznMtlsClientcertValidityHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznTlsCipherSuiteHeaderName"] = args ? args.routingHttpRequestXAmznTlsCipherSuiteHeaderName : undefined;
resourceInputs["routingHttpRequestXAmznTlsVersionHeaderName"] = args ? args.routingHttpRequestXAmznTlsVersionHeaderName : undefined;
resourceInputs["routingHttpResponseAccessControlAllowCredentialsHeaderValue"] = args ? args.routingHttpResponseAccessControlAllowCredentialsHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlAllowHeadersHeaderValue"] = args ? args.routingHttpResponseAccessControlAllowHeadersHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlAllowMethodsHeaderValue"] = args ? args.routingHttpResponseAccessControlAllowMethodsHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlAllowOriginHeaderValue"] = args ? args.routingHttpResponseAccessControlAllowOriginHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlExposeHeadersHeaderValue"] = args ? args.routingHttpResponseAccessControlExposeHeadersHeaderValue : undefined;
resourceInputs["routingHttpResponseAccessControlMaxAgeHeaderValue"] = args ? args.routingHttpResponseAccessControlMaxAgeHeaderValue : undefined;
resourceInputs["routingHttpResponseContentSecurityPolicyHeaderValue"] = args ? args.routingHttpResponseContentSecurityPolicyHeaderValue : undefined;
resourceInputs["routingHttpResponseServerEnabled"] = args ? args.routingHttpResponseServerEnabled : undefined;
resourceInputs["routingHttpResponseStrictTransportSecurityHeaderValue"] = args ? args.routingHttpResponseStrictTransportSecurityHeaderValue : undefined;
resourceInputs["routingHttpResponseXContentTypeOptionsHeaderValue"] = args ? args.routingHttpResponseXContentTypeOptionsHeaderValue : undefined;
resourceInputs["routingHttpResponseXFrameOptionsHeaderValue"] = args ? args.routingHttpResponseXFrameOptionsHeaderValue : undefined;
resourceInputs["sslPolicy"] = args ? args.sslPolicy : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["tcpIdleTimeoutSeconds"] = args ? args.tcpIdleTimeoutSeconds : undefined;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const aliasOpts = { aliases: [{ type: "aws:elasticloadbalancingv2/listener:Listener" }] };
opts = pulumi.mergeOptions(opts, aliasOpts);
super(Listener.__pulumiType, name, resourceInputs, opts);
}
}
exports.Listener = Listener;
/** @internal */
Listener.__pulumiType = 'aws:lb/listener:Listener';
//# sourceMappingURL=listener.js.map