UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

369 lines • 16.9 kB
"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:alb/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, { ...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?.alpnPolicy; resourceInputs["arn"] = state?.arn; resourceInputs["certificateArn"] = state?.certificateArn; resourceInputs["defaultActions"] = state?.defaultActions; resourceInputs["loadBalancerArn"] = state?.loadBalancerArn; resourceInputs["mutualAuthentication"] = state?.mutualAuthentication; resourceInputs["port"] = state?.port; resourceInputs["protocol"] = state?.protocol; resourceInputs["region"] = state?.region; resourceInputs["routingHttpRequestXAmznMtlsClientcertHeaderName"] = state?.routingHttpRequestXAmznMtlsClientcertHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertIssuerHeaderName"] = state?.routingHttpRequestXAmznMtlsClientcertIssuerHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertLeafHeaderName"] = state?.routingHttpRequestXAmznMtlsClientcertLeafHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName"] = state?.routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertSubjectHeaderName"] = state?.routingHttpRequestXAmznMtlsClientcertSubjectHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertValidityHeaderName"] = state?.routingHttpRequestXAmznMtlsClientcertValidityHeaderName; resourceInputs["routingHttpRequestXAmznTlsCipherSuiteHeaderName"] = state?.routingHttpRequestXAmznTlsCipherSuiteHeaderName; resourceInputs["routingHttpRequestXAmznTlsVersionHeaderName"] = state?.routingHttpRequestXAmznTlsVersionHeaderName; resourceInputs["routingHttpResponseAccessControlAllowCredentialsHeaderValue"] = state?.routingHttpResponseAccessControlAllowCredentialsHeaderValue; resourceInputs["routingHttpResponseAccessControlAllowHeadersHeaderValue"] = state?.routingHttpResponseAccessControlAllowHeadersHeaderValue; resourceInputs["routingHttpResponseAccessControlAllowMethodsHeaderValue"] = state?.routingHttpResponseAccessControlAllowMethodsHeaderValue; resourceInputs["routingHttpResponseAccessControlAllowOriginHeaderValue"] = state?.routingHttpResponseAccessControlAllowOriginHeaderValue; resourceInputs["routingHttpResponseAccessControlExposeHeadersHeaderValue"] = state?.routingHttpResponseAccessControlExposeHeadersHeaderValue; resourceInputs["routingHttpResponseAccessControlMaxAgeHeaderValue"] = state?.routingHttpResponseAccessControlMaxAgeHeaderValue; resourceInputs["routingHttpResponseContentSecurityPolicyHeaderValue"] = state?.routingHttpResponseContentSecurityPolicyHeaderValue; resourceInputs["routingHttpResponseServerEnabled"] = state?.routingHttpResponseServerEnabled; resourceInputs["routingHttpResponseStrictTransportSecurityHeaderValue"] = state?.routingHttpResponseStrictTransportSecurityHeaderValue; resourceInputs["routingHttpResponseXContentTypeOptionsHeaderValue"] = state?.routingHttpResponseXContentTypeOptionsHeaderValue; resourceInputs["routingHttpResponseXFrameOptionsHeaderValue"] = state?.routingHttpResponseXFrameOptionsHeaderValue; resourceInputs["sslPolicy"] = state?.sslPolicy; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["tcpIdleTimeoutSeconds"] = state?.tcpIdleTimeoutSeconds; } else { const args = argsOrState; if (args?.defaultActions === undefined && !opts.urn) { throw new Error("Missing required property 'defaultActions'"); } if (args?.loadBalancerArn === undefined && !opts.urn) { throw new Error("Missing required property 'loadBalancerArn'"); } resourceInputs["alpnPolicy"] = args?.alpnPolicy; resourceInputs["certificateArn"] = args?.certificateArn; resourceInputs["defaultActions"] = args?.defaultActions; resourceInputs["loadBalancerArn"] = args?.loadBalancerArn; resourceInputs["mutualAuthentication"] = args?.mutualAuthentication; resourceInputs["port"] = args?.port; resourceInputs["protocol"] = args?.protocol; resourceInputs["region"] = args?.region; resourceInputs["routingHttpRequestXAmznMtlsClientcertHeaderName"] = args?.routingHttpRequestXAmznMtlsClientcertHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertIssuerHeaderName"] = args?.routingHttpRequestXAmznMtlsClientcertIssuerHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertLeafHeaderName"] = args?.routingHttpRequestXAmznMtlsClientcertLeafHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName"] = args?.routingHttpRequestXAmznMtlsClientcertSerialNumberHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertSubjectHeaderName"] = args?.routingHttpRequestXAmznMtlsClientcertSubjectHeaderName; resourceInputs["routingHttpRequestXAmznMtlsClientcertValidityHeaderName"] = args?.routingHttpRequestXAmznMtlsClientcertValidityHeaderName; resourceInputs["routingHttpRequestXAmznTlsCipherSuiteHeaderName"] = args?.routingHttpRequestXAmznTlsCipherSuiteHeaderName; resourceInputs["routingHttpRequestXAmznTlsVersionHeaderName"] = args?.routingHttpRequestXAmznTlsVersionHeaderName; resourceInputs["routingHttpResponseAccessControlAllowCredentialsHeaderValue"] = args?.routingHttpResponseAccessControlAllowCredentialsHeaderValue; resourceInputs["routingHttpResponseAccessControlAllowHeadersHeaderValue"] = args?.routingHttpResponseAccessControlAllowHeadersHeaderValue; resourceInputs["routingHttpResponseAccessControlAllowMethodsHeaderValue"] = args?.routingHttpResponseAccessControlAllowMethodsHeaderValue; resourceInputs["routingHttpResponseAccessControlAllowOriginHeaderValue"] = args?.routingHttpResponseAccessControlAllowOriginHeaderValue; resourceInputs["routingHttpResponseAccessControlExposeHeadersHeaderValue"] = args?.routingHttpResponseAccessControlExposeHeadersHeaderValue; resourceInputs["routingHttpResponseAccessControlMaxAgeHeaderValue"] = args?.routingHttpResponseAccessControlMaxAgeHeaderValue; resourceInputs["routingHttpResponseContentSecurityPolicyHeaderValue"] = args?.routingHttpResponseContentSecurityPolicyHeaderValue; resourceInputs["routingHttpResponseServerEnabled"] = args?.routingHttpResponseServerEnabled; resourceInputs["routingHttpResponseStrictTransportSecurityHeaderValue"] = args?.routingHttpResponseStrictTransportSecurityHeaderValue; resourceInputs["routingHttpResponseXContentTypeOptionsHeaderValue"] = args?.routingHttpResponseXContentTypeOptionsHeaderValue; resourceInputs["routingHttpResponseXFrameOptionsHeaderValue"] = args?.routingHttpResponseXFrameOptionsHeaderValue; resourceInputs["sslPolicy"] = args?.sslPolicy; resourceInputs["tags"] = args?.tags; resourceInputs["tcpIdleTimeoutSeconds"] = args?.tcpIdleTimeoutSeconds; resourceInputs["arn"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "aws:applicationloadbalancing/listener:Listener" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(Listener.__pulumiType, name, resourceInputs, opts); } } exports.Listener = Listener; /** @internal */ Listener.__pulumiType = 'aws:alb/listener:Listener'; //# sourceMappingURL=listener.js.map