mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(lambda): correct Function URL config path from /url-config to /url (#364)
This commit is contained in:
1 parent
34cc0903a8
commit
812ecf6880
4 files changed
+189
-2
No files matched your search
@@ -467,7 +467,10 @@ public class LambdaService {
|
||||
public LambdaUrlConfig createFunctionUrlConfig(String region, String functionName, String qualifier, Map<String, Object> request) {
|
||||
LambdaUrlConfig urlConfig = new LambdaUrlConfig();
|
||||
urlConfig.setAuthType((String) request.getOrDefault("AuthType", "NONE"));
|
||||
|
||||
if (request.containsKey("InvokeMode")) {
|
||||
urlConfig.setInvokeMode((String) request.get("InvokeMode"));
|
||||
}
|
||||
|
||||
String urlId = UUID.nameUUIDFromBytes((region + functionName + (qualifier != null ? qualifier : "")).getBytes()).toString().replace("-", "").substring(0, 32);
|
||||
String baseHost = config.effectiveBaseUrl().replaceFirst("https?://", "");
|
||||
String url = String.format("http://%s.lambda-url.%s.%s/", urlId, region, baseHost);
|
||||
@@ -496,6 +499,7 @@ public class LambdaService {
|
||||
if (alias.getUrlConfig() != null) {
|
||||
throw new AwsException("ResourceConflictException", "Function URL config already exists for alias: " + qualifier, 409);
|
||||
}
|
||||
urlConfig.setFunctionArn(alias.getAliasArn());
|
||||
alias.setUrlConfig(urlConfig);
|
||||
if (aliasStore != null) aliasStore.save(region, alias);
|
||||
} else {
|
||||
@@ -503,6 +507,7 @@ public class LambdaService {
|
||||
if (fn.getUrlConfig() != null) {
|
||||
throw new AwsException("ResourceConflictException", "Function URL config already exists for function: " + functionName, 409);
|
||||
}
|
||||
urlConfig.setFunctionArn(fn.getFunctionArn());
|
||||
fn.setUrlConfig(urlConfig);
|
||||
functionStore.save(region, fn);
|
||||
}
|
||||
@@ -531,6 +536,9 @@ public class LambdaService {
|
||||
if (request.containsKey("AuthType")) {
|
||||
urlConfig.setAuthType((String) request.get("AuthType"));
|
||||
}
|
||||
if (request.containsKey("InvokeMode")) {
|
||||
urlConfig.setInvokeMode((String) request.get("InvokeMode"));
|
||||
}
|
||||
|
||||
String now = DateTimeFormatter.ISO_INSTANT.format(Instant.now().atOffset(ZoneOffset.UTC));
|
||||
urlConfig.setLastModifiedTime(now);
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.Map;
|
||||
/**
|
||||
* AWS Lambda Function URL configuration API.
|
||||
*/
|
||||
@Path("/2021-10-31/functions/{FunctionName}/url-config")
|
||||
@Path("/2021-10-31/functions/{FunctionName}/url")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class LambdaUrlController {
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
package io.github.hectorvent.floci.services.lambda.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class LambdaUrlConfig {
|
||||
|
||||
@JsonProperty("FunctionUrl")
|
||||
private String functionUrl;
|
||||
|
||||
@JsonProperty("FunctionArn")
|
||||
private String functionArn;
|
||||
|
||||
@JsonProperty("AuthType")
|
||||
private String authType; // NONE or AWS_IAM
|
||||
|
||||
@JsonProperty("InvokeMode")
|
||||
private String invokeMode = "BUFFERED";
|
||||
|
||||
@JsonProperty("CreationTime")
|
||||
private String creationTime;
|
||||
|
||||
@JsonProperty("LastModifiedTime")
|
||||
private String lastModifiedTime;
|
||||
|
||||
@JsonProperty("Cors")
|
||||
private Cors cors;
|
||||
|
||||
public LambdaUrlConfig() {}
|
||||
@@ -18,9 +34,15 @@ public class LambdaUrlConfig {
|
||||
public String getFunctionUrl() { return functionUrl; }
|
||||
public void setFunctionUrl(String functionUrl) { this.functionUrl = functionUrl; }
|
||||
|
||||
public String getFunctionArn() { return functionArn; }
|
||||
public void setFunctionArn(String functionArn) { this.functionArn = functionArn; }
|
||||
|
||||
public String getAuthType() { return authType; }
|
||||
public void setAuthType(String authType) { this.authType = authType; }
|
||||
|
||||
public String getInvokeMode() { return invokeMode; }
|
||||
public void setInvokeMode(String invokeMode) { this.invokeMode = invokeMode; }
|
||||
|
||||
public String getCreationTime() { return creationTime; }
|
||||
public void setCreationTime(String creationTime) { this.creationTime = creationTime; }
|
||||
|
||||
@@ -32,11 +54,22 @@ public class LambdaUrlConfig {
|
||||
|
||||
@RegisterForReflection
|
||||
public static class Cors {
|
||||
@JsonProperty("AllowCredentials")
|
||||
private boolean allowCredentials;
|
||||
|
||||
@JsonProperty("AllowHeaders")
|
||||
private String[] allowHeaders;
|
||||
|
||||
@JsonProperty("AllowMethods")
|
||||
private String[] allowMethods;
|
||||
|
||||
@JsonProperty("AllowOrigins")
|
||||
private String[] allowOrigins;
|
||||
|
||||
@JsonProperty("ExposeHeaders")
|
||||
private String[] exposeHeaders;
|
||||
|
||||
@JsonProperty("MaxAge")
|
||||
private Integer maxAge;
|
||||
|
||||
public boolean isAllowCredentials() { return allowCredentials; }
|
||||
|
||||
Reference in new issue
Block a user