Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions docs/guides/cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,9 @@ layers, built by the same generator, as public layers of the account
``959435416781`` in the commercial regions of AWS: of Python, as
``python3_14-arm64`` or ``python3_15t-x86_64``, of one version and one
architecture, for ``provided.al2023``, and of Pyjoyment, as
``pyjoyment-python3_14``, for both architectures, with the layer of Python or
on the runtime ``python3.14``. With ``--function-only``, the generator writes
``pyjoyment-0_3_0-python3_14`` of Pyjoyment 0.3.0, for both architectures,
with the layer of Python or on the runtime ``python3.14``. With
``--function-only``, the generator writes
``function.zip`` alone, for them, and tells the version of Pyjoyment of the
dependencies of the application, which the description of the layer of
Pyjoyment says too. The layer of Pyjoyment has `Pyjo-AWS
Expand All @@ -1193,10 +1194,14 @@ namespace ``Pyjo``, as ``Pyjo-MCP``, stays in the function.
[write] /home/sri/myapp/dist/function.zip

A function takes a layer by the ARN of a version, as
``arn:aws:lambda:<region>:959435416781:layer:pyjoyment-python3_14:<version>``,
``arn:aws:lambda:<region>:959435416781:layer:pyjoyment-0_3_0-python3_14:<version>``,
which the index of the layers of each release, ``layers.json``, gives as
``{layer: {region: arn}}``. The index of the latest release is always at the
same URL, which a one-liner reads with a JSON Pointer.
``{layer: {region: arn}}``. A release has the layers of one version of
Pyjoyment, which come after the release of Pyjoyment, and its tag has the
version and the date, as ``0.3.0+2026.11.05``. Its index has the same layers
under the names without the version too, as ``pyjoyment-python3_14``, so that
the index of the latest release, which is always at the same URL, gives the
layers of the latest Pyjoyment, which a one-liner reads with a JSON Pointer.

.. code-block:: console

Expand All @@ -1206,7 +1211,9 @@ The directories `examples/lambda
<https://github.com/pyjoyment/Pyjoyment/tree/main/examples/lambda>`_ and
`examples/lambda_zip
<https://github.com/pyjoyment/Pyjoyment/tree/main/examples/lambda_zip>`_ of the
repository deploy such functions with OpenTofu.
repository deploy such functions with OpenTofu, with the layers of the latest
release, or of the latest release of a version of Pyjoyment, as the one that
``--function-only`` tells, of the variable ``pyjoyment_version``.

The same function runs locally, mounted in an application with
:mod:`Pyjo.App.Lambda`, in a process of its own, which gets its invocations
Expand Down
8 changes: 8 additions & 0 deletions examples/lambda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ the version of Pyjoyment of the dependencies, which the description of the
layer says too: the inline metadata of the script takes Pyjoyment of the
checkout, which can be newer than the one of the latest release.

`-var pyjoyment_version=0.3.0` takes the layer of the latest release of that
version of Pyjoyment, `pyjoyment-0_3_0-python3_15`, for a function of the
checkout of an older version. Its release is the latest one whose tag has the
version and the date, as `0.3.0+2026.11.05`, in the list of the API of GitHub,
which answers 60 requests an hour of an address without a token. The layers of
a version come after its release, so the checkout of a version that is not
released yet takes the layers of its own build.

`-var public_layers=false` takes the layer of the build in the place of the
public one, which the generator writes without `--function-only`:

Expand Down
2 changes: 1 addition & 1 deletion examples/lambda/function.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "aws_lambda_layer_version" "pyjoyment" {
locals {
pyjoyment_layer = (
var.pyjoyment_layer != null ? var.pyjoyment_layer
: var.public_layers ? local.public_layers["pyjoyment-${local.python_name}"][data.aws_region.current.region]
: var.public_layers ? local.public_layers[local.pyjoyment_name][data.aws_region.current.region]
: aws_lambda_layer_version.pyjoyment.arn
)
}
Expand Down
51 changes: 47 additions & 4 deletions examples/lambda/layers.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
# The index of the public layers of the latest release of Pyjoyment-Lambda-Layers, {layer: {region: arn}}, behind a
# redirection of GitHub, which the provider follows
# The releases of Pyjoyment-Lambda-Layers, for the public layers of a version of Pyjoyment, whose tags have the version
# and the date, as 0.3.0+2026.11.05, as GitHub has no latest release of a prefix. The API of GitHub answers 60 requests
# an hour of an address without a token, and 100 releases at most, in an order of its own
data "http" "releases" {
url = "https://api.github.com/repos/pyjoyment/Pyjoyment-Lambda-Layers/releases?per_page=100"

request_headers = {
Accept = "application/vnd.github+json"
}

lifecycle {
enabled = var.public_layers && var.pyjoyment_version != null

postcondition {
condition = self.status_code == 200
error_message = "The API of GitHub answers ${self.status_code}: ${self.response_body}"
}
}
}

# The tag of the latest release of the version, the last of its releases sorted by the time of their publication
locals {
releases = var.public_layers && var.pyjoyment_version != null ? sort([
for release in jsondecode(data.http.releases.response_body) : "${release.published_at} ${release.tag_name}"
if startswith(release.tag_name, "${var.pyjoyment_version}+")
]) : []
release = length(local.releases) > 0 ? split(" ", local.releases[length(local.releases) - 1])[1] : null
}

# The index of the public layers of the release, {layer: {region: arn}}, or of the latest release, behind a redirection
# of GitHub, which the provider follows
data "http" "layers" {
url = "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json"
url = (
local.release != null
? "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/download/${urlencode(local.release)}/layers.json"
: "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json"
)

lifecycle {
enabled = var.public_layers

precondition {
condition = var.pyjoyment_version == null || local.release != null
error_message = "No release of Pyjoyment-Lambda-Layers of the latest 100 has the layers of the version of Pyjoyment, which come after its release. The variable \"public_layers\" set to false takes the layers of the build."
}
}
}

# The layer of Pyjoyment of the version of Python of the runtime, as pyjoyment-python3_14
# The layer of Pyjoyment of the version of Python of the runtime, as pyjoyment-0_3_0-python3_14 of a version of
# Pyjoyment, or its alias pyjoyment-python3_14 in the index of the latest release
locals {
public_layers = var.public_layers ? jsondecode(data.http.layers.response_body) : {}
python_name = replace(var.runtime, ".", "_")
pyjoyment_name = (
var.pyjoyment_version != null ? "pyjoyment-${replace(var.pyjoyment_version, ".", "_")}-${local.python_name}"
: "pyjoyment-${local.python_name}"
)
}
6 changes: 6 additions & 0 deletions examples/lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ variable "public_layers" {
default = true
}

variable "pyjoyment_version" {
description = "The version of Pyjoyment of the public layers, as \"0.3.0\", the one that \"--function-only\" tells, or the latest one"
type = string
default = null
}

variable "multi_value_headers" {
description = "Whether the load balancer sends the headers and the parameters of the query with all their values"
type = bool
Expand Down
8 changes: 8 additions & 0 deletions examples/lambda_stream/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ the version of Pyjoyment of the dependencies, which the description of the
layer says too: the inline metadata of the script takes Pyjoyment of the
checkout, which can be newer than the one of the latest release.

`-var pyjoyment_version=0.3.0` takes the layer of the latest release of that
version of Pyjoyment, `pyjoyment-0_3_0-python3_15`, for a function of the
checkout of an older version. Its release is the latest one whose tag has the
version and the date, as `0.3.0+2026.11.05`, in the list of the API of GitHub,
which answers 60 requests an hour of an address without a token. The layers of
a version come after its release, so the checkout of a version that is not
released yet takes the layers of its own build.

`-var public_layers=false` takes the layer of the build in the place of the
public one, which the generator writes without `--function-only`:

Expand Down
2 changes: 1 addition & 1 deletion examples/lambda_stream/function.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "aws_lambda_layer_version" "pyjoyment" {
locals {
pyjoyment_layer = (
var.pyjoyment_layer != null ? var.pyjoyment_layer
: var.public_layers ? local.public_layers["pyjoyment-${local.python_name}"][data.aws_region.current.region]
: var.public_layers ? local.public_layers[local.pyjoyment_name][data.aws_region.current.region]
: aws_lambda_layer_version.pyjoyment.arn
)
}
Expand Down
51 changes: 47 additions & 4 deletions examples/lambda_stream/layers.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
# The index of the public layers of the latest release of Pyjoyment-Lambda-Layers, {layer: {region: arn}}, behind a
# redirection of GitHub, which the provider follows
# The releases of Pyjoyment-Lambda-Layers, for the public layers of a version of Pyjoyment, whose tags have the version
# and the date, as 0.3.0+2026.11.05, as GitHub has no latest release of a prefix. The API of GitHub answers 60 requests
# an hour of an address without a token, and 100 releases at most, in an order of its own
data "http" "releases" {
url = "https://api.github.com/repos/pyjoyment/Pyjoyment-Lambda-Layers/releases?per_page=100"

request_headers = {
Accept = "application/vnd.github+json"
}

lifecycle {
enabled = var.public_layers && var.pyjoyment_version != null

postcondition {
condition = self.status_code == 200
error_message = "The API of GitHub answers ${self.status_code}: ${self.response_body}"
}
}
}

# The tag of the latest release of the version, the last of its releases sorted by the time of their publication
locals {
releases = var.public_layers && var.pyjoyment_version != null ? sort([
for release in jsondecode(data.http.releases.response_body) : "${release.published_at} ${release.tag_name}"
if startswith(release.tag_name, "${var.pyjoyment_version}+")
]) : []
release = length(local.releases) > 0 ? split(" ", local.releases[length(local.releases) - 1])[1] : null
}

# The index of the public layers of the release, {layer: {region: arn}}, or of the latest release, behind a redirection
# of GitHub, which the provider follows
data "http" "layers" {
url = "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json"
url = (
local.release != null
? "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/download/${urlencode(local.release)}/layers.json"
: "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json"
)

lifecycle {
enabled = var.public_layers

precondition {
condition = var.pyjoyment_version == null || local.release != null
error_message = "No release of Pyjoyment-Lambda-Layers of the latest 100 has the layers of the version of Pyjoyment, which come after its release. The variable \"public_layers\" set to false takes the layers of the build."
}
}
}

# The layer of Pyjoyment of the version of Python of the runtime, as pyjoyment-python3_14
# The layer of Pyjoyment of the version of Python of the runtime, as pyjoyment-0_3_0-python3_14 of a version of
# Pyjoyment, or its alias pyjoyment-python3_14 in the index of the latest release
locals {
public_layers = var.public_layers ? jsondecode(data.http.layers.response_body) : {}
python_name = replace(var.runtime, ".", "_")
pyjoyment_name = (
var.pyjoyment_version != null ? "pyjoyment-${replace(var.pyjoyment_version, ".", "_")}-${local.python_name}"
: "pyjoyment-${local.python_name}"
)
}
6 changes: 6 additions & 0 deletions examples/lambda_stream/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ variable "public_layers" {
type = bool
default = true
}

variable "pyjoyment_version" {
description = "The version of Pyjoyment of the public layers, as \"0.3.0\", the one that \"--function-only\" tells, or the latest one"
type = string
default = null
}
9 changes: 9 additions & 0 deletions examples/lambda_zip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ description of the layer of Pyjoyment says too: the inline metadata of the
script takes Pyjoyment of the checkout, which can be newer than the one of the
latest release.

`-var pyjoyment_version=0.3.0` takes the layers of the latest release of that
version of Pyjoyment, `pyjoyment-0_3_0-python3_15` and the layer of Python of
the same release, for a function of the checkout of an older version. Its
release is the latest one whose tag has the version and the date, as
`0.3.0+2026.11.05`, in the list of the API of GitHub, which answers 60 requests
an hour of an address without a token. The layers of a version come after its
release, so the checkout of a version that is not released yet takes the layers
of its own build.

`-var public_layers=false` takes the layers of the build in the place of the
public ones, which the generator writes without `--function-only`, with the
Python that runs it, or the one of `--python`:
Expand Down
2 changes: 1 addition & 1 deletion examples/lambda_zip/function.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ locals {
)
pyjoyment_layer = (
var.pyjoyment_layer != null ? var.pyjoyment_layer
: var.public_layers ? local.public_layers["pyjoyment-${local.python_name}"][local.region]
: var.public_layers ? local.public_layers[local.pyjoyment_name][local.region]
: aws_lambda_layer_version.pyjoyment.arn
)
}
Expand Down
51 changes: 47 additions & 4 deletions examples/lambda_zip/layers.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
# The index of the public layers of the latest release of Pyjoyment-Lambda-Layers, {layer: {region: arn}}, behind a
# redirection of GitHub, which the provider follows
# The releases of Pyjoyment-Lambda-Layers, for the public layers of a version of Pyjoyment, whose tags have the version
# and the date, as 0.3.0+2026.11.05, as GitHub has no latest release of a prefix. The API of GitHub answers 60 requests
# an hour of an address without a token, and 100 releases at most, in an order of its own
data "http" "releases" {
url = "https://api.github.com/repos/pyjoyment/Pyjoyment-Lambda-Layers/releases?per_page=100"

request_headers = {
Accept = "application/vnd.github+json"
}

lifecycle {
enabled = var.public_layers && var.pyjoyment_version != null

postcondition {
condition = self.status_code == 200
error_message = "The API of GitHub answers ${self.status_code}: ${self.response_body}"
}
}
}

# The tag of the latest release of the version, the last of its releases sorted by the time of their publication
locals {
releases = var.public_layers && var.pyjoyment_version != null ? sort([
for release in jsondecode(data.http.releases.response_body) : "${release.published_at} ${release.tag_name}"
if startswith(release.tag_name, "${var.pyjoyment_version}+")
]) : []
release = length(local.releases) > 0 ? split(" ", local.releases[length(local.releases) - 1])[1] : null
}

# The index of the public layers of the release, {layer: {region: arn}}, or of the latest release, behind a redirection
# of GitHub, which the provider follows
data "http" "layers" {
url = "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json"
url = (
local.release != null
? "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/download/${urlencode(local.release)}/layers.json"
: "https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json"
)

lifecycle {
enabled = var.public_layers

precondition {
condition = var.pyjoyment_version == null || local.release != null
error_message = "No release of Pyjoyment-Lambda-Layers of the latest 100 has the layers of the version of Pyjoyment, which come after its release. The variable \"public_layers\" set to false takes the layers of the build."
}
}
}

# The names of the layers of the version of Python, as python3_15-arm64 and pyjoyment-python3_15
# The names of the layers of the version of Python, as python3_15-arm64, and pyjoyment-0_3_0-python3_15 of a version of
# Pyjoyment, or its alias pyjoyment-python3_15 in the index of the latest release
locals {
public_layers = var.public_layers ? jsondecode(data.http.layers.response_body) : {}
python_name = "python${replace(var.python, ".", "_")}"
pyjoyment_name = (
var.pyjoyment_version != null ? "pyjoyment-${replace(var.pyjoyment_version, ".", "_")}-${local.python_name}"
: "pyjoyment-${local.python_name}"
)
}
6 changes: 6 additions & 0 deletions examples/lambda_zip/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ variable "public_layers" {
default = true
}

variable "pyjoyment_version" {
description = "The version of Pyjoyment of the public layers, as \"0.3.0\", the one that \"--function-only\" tells, or the latest one"
type = string
default = null
}

variable "python" {
description = "The version of Python of the public layers, as \"3.15\" or \"3.15t\""
type = string
Expand Down
11 changes: 8 additions & 3 deletions plugins/pyjoyment/skills/deploy/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,16 @@ kubectl apply -k kubernetes/prod
- The public layers of
[Pyjoyment-Lambda-Layers](https://github.com/pyjoyment/Pyjoyment-Lambda-Layers),
as `python3_14-arm64` of Python for `provided.al2023` and
`pyjoyment-python3_14` of Pyjoyment, also for the runtime `python3.14`, are
taken by the ARN of a version, which the index of the latest release gives:
`pyjoyment-0_3_0-python3_14` of Pyjoyment 0.3.0, also for the runtime
`python3.14`, are taken by the ARN of a version, which the index of a
release gives, with the aliases of the latest Pyjoyment, as
`pyjoyment-python3_14`, in the index of the latest release:
`python -m Pyjo 'g("https://github.com/pyjoyment/Pyjoyment-Lambda-Layers/releases/latest/download/layers.json").json("/pyjoyment-python3_14/eu-central-1")'`.
`--function-only` tells the version of Pyjoyment of the dependencies, which
the layer of Pyjoyment is to have. The public layer of Pyjoyment has
the layer of Pyjoyment is to have: the layers of an older version are in
the latest release whose tag has it, as `0.3.0+2026.11.05`, and those of a
version come after its release, so a function of an unreleased checkout
takes a layer of its own build. The public layer of Pyjoyment has
Pyjo-AWS too: `--layer-package Pyjo-AWS` leaves it out of the function, as
the layer of its own build does, while another distribution of the namespace
`Pyjo`, as Pyjo-MCP, stays in the function.
Expand Down
Loading