aws.lambda.getFunctionUrl
Provides details about an AWS Lambda Function URL. Use this data source to retrieve information about an existing function URL configuration.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.lambda.getFunctionUrl({
functionName: "my_lambda_function",
});
export const functionUrl = example.then(example => example.functionUrl);
import pulumi
import pulumi_aws as aws
example = aws.lambda.get_function_url(function_name="my_lambda_function")
pulumi.export("functionUrl", example.function_url)
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := lambda.LookupFunctionUrl(ctx, &lambda.LookupFunctionUrlArgs{
FunctionName: "my_lambda_function",
}, nil)
if err != nil {
return err
}
ctx.Export("functionUrl", example.FunctionUrl)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Lambda.GetFunctionUrl.Invoke(new()
{
FunctionName = "my_lambda_function",
});
return new Dictionary<string, object?>
{
["functionUrl"] = example.Apply(getFunctionUrlResult => getFunctionUrlResult.FunctionUrl),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.LambdaFunctions;
import com.pulumi.aws.lambda.inputs.GetFunctionUrlArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = LambdaFunctions.getFunctionUrl(GetFunctionUrlArgs.builder()
.functionName("my_lambda_function")
.build());
ctx.export("functionUrl", example.functionUrl());
}
}
variables:
example:
fn::invoke:
function: aws:lambda:getFunctionUrl
arguments:
functionName: my_lambda_function
outputs:
functionUrl: ${example.functionUrl}
With Qualifier
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as std from "@pulumi/std";
const example = aws.lambda.getFunctionUrl({
functionName: exampleAwsLambdaFunction.functionName,
qualifier: "production",
});
// Use the URL in other resources
const lambdaAlias = new aws.route53.Record("lambda_alias", {
zoneId: exampleAwsRoute53Zone.zoneId,
name: "api.example.com",
type: aws.route53.RecordType.CNAME,
ttl: 300,
records: [example.then(example => std.replace({
text: example.functionUrl,
search: "https://",
replace: "",
})).then(invoke => invoke.result)],
});
import pulumi
import pulumi_aws as aws
import pulumi_std as std
example = aws.lambda.get_function_url(function_name=example_aws_lambda_function["functionName"],
qualifier="production")
# Use the URL in other resources
lambda_alias = aws.route53.Record("lambda_alias",
zone_id=example_aws_route53_zone["zoneId"],
name="api.example.com",
type=aws.route53.RecordType.CNAME,
ttl=300,
records=[std.replace(text=example.function_url,
search="https://",
replace="").result])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/route53"
"github.com/pulumi/pulumi-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := lambda.LookupFunctionUrl(ctx, &lambda.LookupFunctionUrlArgs{
FunctionName: exampleAwsLambdaFunction.FunctionName,
Qualifier: pulumi.StringRef("production"),
}, nil)
if err != nil {
return err
}
invokeReplace, err := std.Replace(ctx, &std.ReplaceArgs{
Text: example.FunctionUrl,
Search: "https://",
Replace: "",
}, nil)
if err != nil {
return err
}
// Use the URL in other resources
_, err = route53.NewRecord(ctx, "lambda_alias", &route53.RecordArgs{
ZoneId: pulumi.Any(exampleAwsRoute53Zone.ZoneId),
Name: pulumi.String("api.example.com"),
Type: pulumi.String(route53.RecordTypeCNAME),
Ttl: pulumi.Int(300),
Records: pulumi.StringArray{
pulumi.String(invokeReplace.Result),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var example = Aws.Lambda.GetFunctionUrl.Invoke(new()
{
FunctionName = exampleAwsLambdaFunction.FunctionName,
Qualifier = "production",
});
// Use the URL in other resources
var lambdaAlias = new Aws.Route53.Record("lambda_alias", new()
{
ZoneId = exampleAwsRoute53Zone.ZoneId,
Name = "api.example.com",
Type = Aws.Route53.RecordType.CNAME,
Ttl = 300,
Records = new[]
{
Std.Replace.Invoke(new()
{
Text = example.Apply(getFunctionUrlResult => getFunctionUrlResult.FunctionUrl),
Search = "https://",
Replace = "",
}).Apply(invoke => invoke.Result),
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.LambdaFunctions;
import com.pulumi.aws.lambda.inputs.GetFunctionUrlArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.ReplaceArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = LambdaFunctions.getFunctionUrl(GetFunctionUrlArgs.builder()
.functionName(exampleAwsLambdaFunction.functionName())
.qualifier("production")
.build());
// Use the URL in other resources
var lambdaAlias = new Record("lambdaAlias", RecordArgs.builder()
.zoneId(exampleAwsRoute53Zone.zoneId())
.name("api.example.com")
.type("CNAME")
.ttl(300)
.records(StdFunctions.replace(ReplaceArgs.builder()
.text(example.functionUrl())
.search("https://")
.replace("")
.build()).result())
.build());
}
}
resources:
# Use the URL in other resources
lambdaAlias:
type: aws:route53:Record
name: lambda_alias
properties:
zoneId: ${exampleAwsRoute53Zone.zoneId}
name: api.example.com
type: CNAME
ttl: 300
records:
- fn::invoke:
function: std:replace
arguments:
text: ${example.functionUrl}
search: https://
replace: ""
return: result
variables:
example:
fn::invoke:
function: aws:lambda:getFunctionUrl
arguments:
functionName: ${exampleAwsLambdaFunction.functionName}
qualifier: production
Retrieve CORS Configuration
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.lambda.getFunctionUrl({
functionName: "api_function",
});
const corsConfig = pulumi.all([example.then(example => example.cors).length, example]).apply(([length, example]) => length > 0 ? example.cors?.[0] : null);
const allowedOrigins = corsConfig != null ? corsConfig?.allowOrigins : [];
export const corsAllowedOrigins = allowedOrigins;
import pulumi
import pulumi_aws as aws
example = aws.lambda.get_function_url(function_name="api_function")
cors_config = len(example.cors).apply(lambda length: example.cors[0] if length > 0 else None)
allowed_origins = cors_config["allowOrigins"] if cors_config != None else []
pulumi.export("corsAllowedOrigins", allowed_origins)
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/lambda"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := lambda.LookupFunctionUrl(ctx, &lambda.LookupFunctionUrlArgs{
FunctionName: "api_function",
}, nil);
if err != nil {
return err
}
var tmp0
if length > 0 {
tmp0 = example.Cors[0]
} else {
tmp0 = nil
}
corsConfig := len(example.Cors).ApplyT(func(length int) (lambda.GetFunctionUrlCor, error) {
return tmp0, nil
}).(lambda.GetFunctionUrlCorOutput)
var tmp1 interface{}
if corsConfig != nil {
tmp1 = corsConfig.AllowOrigins
} else {
tmp1 = []interface{}{
}
}
allowedOrigins := tmp1;
ctx.Export("corsAllowedOrigins", allowedOrigins)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Lambda.GetFunctionUrl.Invoke(new()
{
FunctionName = "api_function",
});
var corsConfig = Output.Tuple(example.Apply(getFunctionUrlResult => getFunctionUrlResult.Cors).Length, example).Apply(values =>
{
var length = values.Item1;
var example = values.Item2;
return length > 0 ? example.Apply(getFunctionUrlResult => getFunctionUrlResult.Cors[0]) : null;
});
var allowedOrigins = corsConfig != null ? corsConfig?.AllowOrigins : new[] {};
return new Dictionary<string, object?>
{
["corsAllowedOrigins"] = allowedOrigins,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.lambda.LambdaFunctions;
import com.pulumi.aws.lambda.inputs.GetFunctionUrlArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var example = LambdaFunctions.getFunctionUrl(GetFunctionUrlArgs.builder()
.functionName("api_function")
.build());
final var corsConfig = example.cors().length().applyValue(_length -> _length > 0 ? example.cors()[0] : null);
final var allowedOrigins = corsConfig != null ? corsConfig.allowOrigins() : List.of();
ctx.export("corsAllowedOrigins", allowedOrigins);
}
}
Example coming soon!
Using getFunctionUrl
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getFunctionUrl(args: GetFunctionUrlArgs, opts?: InvokeOptions): Promise<GetFunctionUrlResult>
function getFunctionUrlOutput(args: GetFunctionUrlOutputArgs, opts?: InvokeOptions): Output<GetFunctionUrlResult>def get_function_url(function_name: Optional[str] = None,
qualifier: Optional[str] = None,
region: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetFunctionUrlResult
def get_function_url_output(function_name: Optional[pulumi.Input[str]] = None,
qualifier: Optional[pulumi.Input[str]] = None,
region: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetFunctionUrlResult]func LookupFunctionUrl(ctx *Context, args *LookupFunctionUrlArgs, opts ...InvokeOption) (*LookupFunctionUrlResult, error)
func LookupFunctionUrlOutput(ctx *Context, args *LookupFunctionUrlOutputArgs, opts ...InvokeOption) LookupFunctionUrlResultOutput> Note: This function is named LookupFunctionUrl in the Go SDK.
public static class GetFunctionUrl
{
public static Task<GetFunctionUrlResult> InvokeAsync(GetFunctionUrlArgs args, InvokeOptions? opts = null)
public static Output<GetFunctionUrlResult> Invoke(GetFunctionUrlInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetFunctionUrlResult> getFunctionUrl(GetFunctionUrlArgs args, InvokeOptions options)
public static Output<GetFunctionUrlResult> getFunctionUrl(GetFunctionUrlArgs args, InvokeOptions options)
fn::invoke:
function: aws:lambda/getFunctionUrl:getFunctionUrl
arguments:
# arguments dictionaryThe following arguments are supported:
- Function
Name string Name or ARN of the Lambda function.
The following arguments are optional:
- Qualifier string
- Alias name or
$LATEST. - Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- Function
Name string Name or ARN of the Lambda function.
The following arguments are optional:
- Qualifier string
- Alias name or
$LATEST. - Region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- function
Name String Name or ARN of the Lambda function.
The following arguments are optional:
- qualifier String
- Alias name or
$LATEST. - region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- function
Name string Name or ARN of the Lambda function.
The following arguments are optional:
- qualifier string
- Alias name or
$LATEST. - region string
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- function_
name str Name or ARN of the Lambda function.
The following arguments are optional:
- qualifier str
- Alias name or
$LATEST. - region str
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
- function
Name String Name or ARN of the Lambda function.
The following arguments are optional:
- qualifier String
- Alias name or
$LATEST. - region String
- Region where this resource will be managed. Defaults to the Region set in the provider configuration.
getFunctionUrl Result
The following output properties are available:
- string
- Type of authentication that the function URL uses.
- Cors
List<Get
Function Url Cor> - Cross-origin resource sharing (CORS) settings for the function URL. See below.
- Creation
Time string - When the function URL was created, in ISO-8601 format.
- Function
Arn string - ARN of the function.
- Function
Name string - Function
Url string - HTTP URL endpoint for the function in the format
https://<url_id>.lambda-url.<region>.on.aws/. - Id string
- The provider-assigned unique ID for this managed resource.
- Invoke
Mode string - Whether the Lambda function responds in
BUFFEREDorRESPONSE_STREAMmode. - Last
Modified stringTime - When the function URL configuration was last updated, in ISO-8601 format.
- Region string
- Url
Id string - Generated ID for the endpoint.
- Qualifier string
- string
- Type of authentication that the function URL uses.
- Cors
[]Get
Function Url Cor - Cross-origin resource sharing (CORS) settings for the function URL. See below.
- Creation
Time string - When the function URL was created, in ISO-8601 format.
- Function
Arn string - ARN of the function.
- Function
Name string - Function
Url string - HTTP URL endpoint for the function in the format
https://<url_id>.lambda-url.<region>.on.aws/. - Id string
- The provider-assigned unique ID for this managed resource.
- Invoke
Mode string - Whether the Lambda function responds in
BUFFEREDorRESPONSE_STREAMmode. - Last
Modified stringTime - When the function URL configuration was last updated, in ISO-8601 format.
- Region string
- Url
Id string - Generated ID for the endpoint.
- Qualifier string
- String
- Type of authentication that the function URL uses.
- cors
List<Get
Function Url Cor> - Cross-origin resource sharing (CORS) settings for the function URL. See below.
- creation
Time String - When the function URL was created, in ISO-8601 format.
- function
Arn String - ARN of the function.
- function
Name String - function
Url String - HTTP URL endpoint for the function in the format
https://<url_id>.lambda-url.<region>.on.aws/. - id String
- The provider-assigned unique ID for this managed resource.
- invoke
Mode String - Whether the Lambda function responds in
BUFFEREDorRESPONSE_STREAMmode. - last
Modified StringTime - When the function URL configuration was last updated, in ISO-8601 format.
- region String
- url
Id String - Generated ID for the endpoint.
- qualifier String
- string
- Type of authentication that the function URL uses.
- cors
Get
Function Url Cor[] - Cross-origin resource sharing (CORS) settings for the function URL. See below.
- creation
Time string - When the function URL was created, in ISO-8601 format.
- function
Arn string - ARN of the function.
- function
Name string - function
Url string - HTTP URL endpoint for the function in the format
https://<url_id>.lambda-url.<region>.on.aws/. - id string
- The provider-assigned unique ID for this managed resource.
- invoke
Mode string - Whether the Lambda function responds in
BUFFEREDorRESPONSE_STREAMmode. - last
Modified stringTime - When the function URL configuration was last updated, in ISO-8601 format.
- region string
- url
Id string - Generated ID for the endpoint.
- qualifier string
- str
- Type of authentication that the function URL uses.
- cors
Sequence[Get
Function Url Cor] - Cross-origin resource sharing (CORS) settings for the function URL. See below.
- creation_
time str - When the function URL was created, in ISO-8601 format.
- function_
arn str - ARN of the function.
- function_
name str - function_
url str - HTTP URL endpoint for the function in the format
https://<url_id>.lambda-url.<region>.on.aws/. - id str
- The provider-assigned unique ID for this managed resource.
- invoke_
mode str - Whether the Lambda function responds in
BUFFEREDorRESPONSE_STREAMmode. - last_
modified_ strtime - When the function URL configuration was last updated, in ISO-8601 format.
- region str
- url_
id str - Generated ID for the endpoint.
- qualifier str
- String
- Type of authentication that the function URL uses.
- cors List<Property Map>
- Cross-origin resource sharing (CORS) settings for the function URL. See below.
- creation
Time String - When the function URL was created, in ISO-8601 format.
- function
Arn String - ARN of the function.
- function
Name String - function
Url String - HTTP URL endpoint for the function in the format
https://<url_id>.lambda-url.<region>.on.aws/. - id String
- The provider-assigned unique ID for this managed resource.
- invoke
Mode String - Whether the Lambda function responds in
BUFFEREDorRESPONSE_STREAMmode. - last
Modified StringTime - When the function URL configuration was last updated, in ISO-8601 format.
- region String
- url
Id String - Generated ID for the endpoint.
- qualifier String
Supporting Types
GetFunctionUrlCor
- Allow
Credentials bool - Whether credentials are included in the CORS request.
- Allow
Headers List<string> - List of headers that are specified in the Access-Control-Request-Headers header.
- Allow
Methods List<string> - List of HTTP methods that are allowed when calling the function URL.
- Allow
Origins List<string> - List of origins that are allowed to make requests to the function URL.
- Expose
Headers List<string> - List of headers in the response that you want to expose to the origin that called the function URL.
- Max
Age int - Maximum amount of time, in seconds, that web browsers can cache results of a preflight request.
- Allow
Credentials bool - Whether credentials are included in the CORS request.
- Allow
Headers []string - List of headers that are specified in the Access-Control-Request-Headers header.
- Allow
Methods []string - List of HTTP methods that are allowed when calling the function URL.
- Allow
Origins []string - List of origins that are allowed to make requests to the function URL.
- Expose
Headers []string - List of headers in the response that you want to expose to the origin that called the function URL.
- Max
Age int - Maximum amount of time, in seconds, that web browsers can cache results of a preflight request.
- allow
Credentials Boolean - Whether credentials are included in the CORS request.
- allow
Headers List<String> - List of headers that are specified in the Access-Control-Request-Headers header.
- allow
Methods List<String> - List of HTTP methods that are allowed when calling the function URL.
- allow
Origins List<String> - List of origins that are allowed to make requests to the function URL.
- expose
Headers List<String> - List of headers in the response that you want to expose to the origin that called the function URL.
- max
Age Integer - Maximum amount of time, in seconds, that web browsers can cache results of a preflight request.
- allow
Credentials boolean - Whether credentials are included in the CORS request.
- allow
Headers string[] - List of headers that are specified in the Access-Control-Request-Headers header.
- allow
Methods string[] - List of HTTP methods that are allowed when calling the function URL.
- allow
Origins string[] - List of origins that are allowed to make requests to the function URL.
- expose
Headers string[] - List of headers in the response that you want to expose to the origin that called the function URL.
- max
Age number - Maximum amount of time, in seconds, that web browsers can cache results of a preflight request.
- allow_
credentials bool - Whether credentials are included in the CORS request.
- allow_
headers Sequence[str] - List of headers that are specified in the Access-Control-Request-Headers header.
- allow_
methods Sequence[str] - List of HTTP methods that are allowed when calling the function URL.
- allow_
origins Sequence[str] - List of origins that are allowed to make requests to the function URL.
- expose_
headers Sequence[str] - List of headers in the response that you want to expose to the origin that called the function URL.
- max_
age int - Maximum amount of time, in seconds, that web browsers can cache results of a preflight request.
- allow
Credentials Boolean - Whether credentials are included in the CORS request.
- allow
Headers List<String> - List of headers that are specified in the Access-Control-Request-Headers header.
- allow
Methods List<String> - List of HTTP methods that are allowed when calling the function URL.
- allow
Origins List<String> - List of origins that are allowed to make requests to the function URL.
- expose
Headers List<String> - List of headers in the response that you want to expose to the origin that called the function URL.
- max
Age Number - Maximum amount of time, in seconds, that web browsers can cache results of a preflight request.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
