Skip to content

Commit

Permalink
feat: Support Runtime management controls (aws#420)
Browse files Browse the repository at this point in the history
* feat: Support Runtime management controls

- Modify ECR repo from `/sam/emulation-<runtime>` to `/lambda/<runtime>`.
- Keep RAPID image up-to-date with the remote environment.
- Remove SAM cli version from RAPID image tag locally.
  - These modifications change the rapid image tag
    from `python3.7-rapid-1.2.0-x86_64` to `3.7-rapid-x86_64`,
    since now the runtime name is part of the image *name* and not the tag.
- Support a `RuntimeManagementConfig` in SAM templates and show a message
  if a runtime version is pinned in the template when invoking.
- Rename some variables when building the rapid image, for more clarity.

* PR feedback. Add placeholder text

* Last updates for RuntimeManagementConfiguration

- Change from RuntimeVersion to RuntimeVersion Arn
- Update the message when user has a RuntimeVersion in their template
and wants to invoke locally.

* Update with latest tranform changes

* update tests with latest transform changes

* rollback dev version of SAMT

Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
  • Loading branch information
valerena and mndeveci authored Jan 24, 2023
1 parent 5e90c50 commit 5ea8464
Show file tree
Hide file tree
Showing 19 changed files with 552 additions and 131 deletions.
1 change: 1 addition & 0 deletions samcli/commands/local/lib/local_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def get_invoke_config(self, function: Function) -> FunctionConfig:
memory=function.memory,
timeout=function_timeout,
env_vars=env_vars,
runtime_management_config=function.runtime_management_config,
)

def _make_env_vars(self, function: Function) -> EnvironmentVariables:
Expand Down
2 changes: 2 additions & 0 deletions samcli/lib/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class Function(NamedTuple):
function_url_config: Optional[Dict]
# The path of the stack relative to the root stack, it is empty for functions in root stack
stack_path: str = ""
# Configuration for runtime management. Includes the fields `UpdateRuntimeOn` and `RuntimeVersionArn` (optional).
runtime_management_config: Optional[Dict] = None

@property
def full_path(self) -> str:
Expand Down
1 change: 1 addition & 0 deletions samcli/lib/providers/sam_function_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def _build_function_configuration(
codesign_config_arn=resource_properties.get("CodeSigningConfigArn", None),
architectures=resource_properties.get("Architectures", None),
function_url_config=resource_properties.get("FunctionUrlConfig"),
runtime_management_config=resource_properties.get("RuntimeManagementConfig"),
)

@staticmethod
Expand Down
6 changes: 0 additions & 6 deletions samcli/lib/samlib/local_uri_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ class SupportLocalUriPlugin(BasePlugin):

_SERVERLESS_FUNCTION = "AWS::Serverless::Function"

def __init__(self):
"""
Initialize the plugin
"""
super().__init__(SupportLocalUriPlugin.__name__)

def on_before_transform_resource(self, logical_id, resource_type, resource_properties):

if resource_type == self._SERVERLESS_FUNCTION and not resource_properties.get("CodeUri"):
Expand Down
4 changes: 2 additions & 2 deletions samcli/lib/samlib/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
InvalidResourceException,
InvalidEventException,
)
from samtranslator.model.types import is_str
from samtranslator.model.types import IS_STR
from samtranslator.plugins import LifeCycleEvents
from samtranslator.sdk.resource import SamResource, SamResourceType
from samtranslator.translator.translator import prepare_plugins
Expand Down Expand Up @@ -92,7 +92,7 @@ def _patch_language_extensions(self) -> None:

def patched_func(self):
if self.condition:
if not is_str()(self.condition, should_raise=False):
if not IS_STR(self.condition, should_raise=False):
raise InvalidDocumentException(
[InvalidTemplateException("Every Condition member must be a string.")]
)
Expand Down
Loading

0 comments on commit 5ea8464

Please sign in to comment.