Skip to content

Commit

Permalink
style(*): make constants
Browse files Browse the repository at this point in the history
  • Loading branch information
windmgc committed May 15, 2024
1 parent 7d7c41b commit f41554c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/resty/aws/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ local execute_request = require("resty.aws.request.execute")
local split = require("pl.utils").split
local tablex = require("pl.tablex")

local AWS_PUBLIC_DOMAIN_PATTERN = "^(.+)(%.amazonaws%.com)$"
local AWS_VPC_ENDPOINT_DOMAIN_PATTERN = "^(.+)(%.vpce%.amazonaws%.com)$"


-- case-insensitive lookup help.
Expand Down Expand Up @@ -326,8 +328,8 @@ local function generate_service_methods(service)
-- If the endpoint is a VPC endpoint DNS hostname then we don't need to inject the region
-- VPC endpoint DNS hostnames always contain region, see
-- https://docs.aws.amazon.com/vpc/latest/privatelink/privatelink-access-aws-services.html#interface-endpoint-dns-hostnames
if not service.config._regionalEndpointInjected and not service.config.endpoint:match("^(.+)(%.vpce%.amazonaws%.com)$") then
local pre, post = service.config.endpoint:match("^(.+)(%.amazonaws%.com)$")
if not service.config._regionalEndpointInjected and not service.config.endpoint:match(AWS_VPC_ENDPOINT_DOMAIN_PATTERN) then
local pre, post = service.config.endpoint:match(AWS_PUBLIC_DOMAIN_PATTERN)
service.config.endpoint = pre .. "." .. service.config.region .. post
service.config.signingRegion = service.config.region
service.config._regionalEndpointInjected = true
Expand Down

0 comments on commit f41554c

Please sign in to comment.