-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add helper module to determine
code_uri
This commit replaces how we map "version" to code URI for our lambda functions. Previously we maintained a hardcoded mapping of `region` to `code_uri` for each binary, e.g: ``` region,code_uri ap-south-1,s3://observeinc-ap-south-1/apps/forwarder/1.19.2/faceca9e757102324a1fa722b95f8546 eu-north-1,s3://observeinc-eu-north-1/apps/forwarder/1.19.2/e4bfefb742254a45b1db834cb9e70c89 ``` This was successful in ensuring that a given terraform module version had a pinned binary version, but allowed no flexibility for overriding version. We now dynamically resolve the code URI by downloading the cloudformation template and parsing out the expected property. This has the disadvantage that it tightly couples us to S3 and our cloudformation template, but arguably both must work for the Lambda install process to work.
- Loading branch information
Showing
25 changed files
with
176 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.19.3 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SAM Version | ||
|
||
This is a helper module that given a SAM App name and Lambda function resource ID returns the code URI. | ||
|
||
## Usage | ||
|
||
```hcl | ||
module "samversion" { | ||
app = "forwarder" | ||
function = "Forwarder" | ||
release_version = "1.19.3" | ||
} | ||
``` | ||
|
||
If `release_version` is omitted, we will default to a value that is updated by `updatecli`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
locals { | ||
latest_release = "1.19.3" | ||
code_version = var.release != "" ? var.release : local.latest_release | ||
code_uri = yamldecode(data.http.manifest.response_body)["Resources"][var.function]["Properties"]["CodeUri"] | ||
} | ||
|
||
data "aws_region" "current" {} | ||
|
||
data "http" "manifest" { | ||
url = "https://observeinc-${data.aws_region.current.name}.s3.amazonaws.com/aws-sam-apps/${local.code_version}/${var.app}.yaml" | ||
|
||
lifecycle { | ||
postcondition { | ||
condition = self.status_code == 200 && can(yamldecode(self.response_body)) | ||
error_message = "Unable to retrieve manifest" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "code_uri" { | ||
description = "Code URI for binary." | ||
value = local.code_uri | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
variable "app" { | ||
description = "App name" | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "function" { | ||
description = "Function name" | ||
type = string | ||
nullable = false | ||
} | ||
|
||
variable "release" { | ||
description = "Release version on github.com/observeinc/aws-sam-apps." | ||
type = string | ||
default = "" | ||
nullable = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
terraform { | ||
required_version = ">= 1.3" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.0" | ||
} | ||
|
||
http = { | ||
source = "hashicorp/http" | ||
version = ">= 3.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.