UNPKG

@pulumi/aws

Version:

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

243 lines • 8.49 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.ListenerRule = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides a Load Balancer Listener Rule resource. * * > **Note:** `aws.alb.ListenerRule` is known as `aws.lb.ListenerRule`. The functionality is identical. * * ## Example Usage * * ```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", {}); * const static = new aws.lb.ListenerRule("static", { * listenerArn: frontEndListener.arn, * priority: 100, * actions: [{ * type: "forward", * targetGroupArn: staticAwsLbTargetGroup.arn, * }], * conditions: [ * { * pathPattern: { * values: ["/static/*"], * }, * }, * { * hostHeader: { * values: ["example.com"], * }, * }, * ], * }); * // Forward action * const hostBasedWeightedRouting = new aws.lb.ListenerRule("host_based_weighted_routing", { * listenerArn: frontEndListener.arn, * priority: 99, * actions: [{ * type: "forward", * targetGroupArn: staticAwsLbTargetGroup.arn, * }], * conditions: [{ * hostHeader: { * values: ["my-service.*.mycompany.io"], * }, * }], * }); * // Weighted Forward action * const hostBasedRouting = new aws.lb.ListenerRule("host_based_routing", { * listenerArn: frontEndListener.arn, * priority: 99, * actions: [{ * type: "forward", * forward: { * targetGroups: [ * { * arn: main.arn, * weight: 80, * }, * { * arn: canary.arn, * weight: 20, * }, * ], * stickiness: { * enabled: true, * duration: 600, * }, * }, * }], * conditions: [{ * hostHeader: { * values: ["my-service.*.mycompany.io"], * }, * }], * }); * // Redirect action * const redirectHttpToHttps = new aws.lb.ListenerRule("redirect_http_to_https", { * listenerArn: frontEndListener.arn, * actions: [{ * type: "redirect", * redirect: { * port: "443", * protocol: "HTTPS", * statusCode: "HTTP_301", * }, * }], * conditions: [{ * httpHeader: { * httpHeaderName: "X-Forwarded-For", * values: ["192.168.1.*"], * }, * }], * }); * // Fixed-response action * const healthCheck = new aws.lb.ListenerRule("health_check", { * listenerArn: frontEndListener.arn, * actions: [{ * type: "fixed-response", * fixedResponse: { * contentType: "text/plain", * messageBody: "HEALTHY", * statusCode: "200", * }, * }], * conditions: [{ * queryStrings: [ * { * key: "health", * value: "check", * }, * { * value: "bar", * }, * ], * }], * }); * // Authenticate-cognito Action * const pool = new aws.cognito.UserPool("pool", {}); * const client = new aws.cognito.UserPoolClient("client", {}); * const domain = new aws.cognito.UserPoolDomain("domain", {}); * const admin = new aws.lb.ListenerRule("admin", { * listenerArn: frontEndListener.arn, * actions: [ * { * type: "authenticate-cognito", * authenticateCognito: { * userPoolArn: pool.arn, * userPoolClientId: client.id, * userPoolDomain: domain.domain, * }, * }, * { * type: "forward", * targetGroupArn: staticAwsLbTargetGroup.arn, * }, * ], * }); * // Authenticate-oidc Action * const oidc = new aws.lb.ListenerRule("oidc", { * listenerArn: frontEndListener.arn, * actions: [ * { * 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: staticAwsLbTargetGroup.arn, * }, * ], * }); * ``` * * ## Import * * Using `pulumi import`, import rules using their ARN. For example: * * ```sh * $ pulumi import aws:lb/listenerRule:ListenerRule front_end arn:aws:elasticloadbalancing:us-west-2:187416307283:listener-rule/app/test/8e4497da625e2d8a/9ab28ade35828f96/67b3d2d36dd7c26b * ``` */ class ListenerRule extends pulumi.CustomResource { /** * Get an existing ListenerRule 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 ListenerRule(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of ListenerRule. 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'] === ListenerRule.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["actions"] = state?.actions; resourceInputs["arn"] = state?.arn; resourceInputs["conditions"] = state?.conditions; resourceInputs["listenerArn"] = state?.listenerArn; resourceInputs["priority"] = state?.priority; resourceInputs["region"] = state?.region; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; } else { const args = argsOrState; if (args?.actions === undefined && !opts.urn) { throw new Error("Missing required property 'actions'"); } if (args?.conditions === undefined && !opts.urn) { throw new Error("Missing required property 'conditions'"); } if (args?.listenerArn === undefined && !opts.urn) { throw new Error("Missing required property 'listenerArn'"); } resourceInputs["actions"] = args?.actions; resourceInputs["conditions"] = args?.conditions; resourceInputs["listenerArn"] = args?.listenerArn; resourceInputs["priority"] = args?.priority; resourceInputs["region"] = args?.region; resourceInputs["tags"] = args?.tags; resourceInputs["arn"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "aws:elasticloadbalancingv2/listenerRule:ListenerRule" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(ListenerRule.__pulumiType, name, resourceInputs, opts); } } exports.ListenerRule = ListenerRule; /** @internal */ ListenerRule.__pulumiType = 'aws:lb/listenerRule:ListenerRule'; //# sourceMappingURL=listenerRule.js.map