def dump_context_to_ssm(context: V) -> None:
        _logger.debug("Writing context to SSM parameter.")

        if isinstance(context, Context):
            _logger.debug("Teams: %s", [t.name for t in context.teams])
            content: Dict[str, Any] = cast(Dict[str, Any],
                                           Context.Schema().dump(context))
            current_teams_contexts: List[str] = ssm.list_teams_contexts(
                env_name=context.name)
            written_teams_contexts: List[str] = []
            for team in content["Teams"]:
                ssm.put_parameter(name=team["SsmParameterName"], obj=team)
                written_teams_contexts.append(team["SsmParameterName"])
            old_teams_contexts: List[str] = list(
                set(current_teams_contexts) - set(written_teams_contexts))
            _logger.debug("old_teams_contexts: %s", old_teams_contexts)
            ssm.delete_parameters(parameters=old_teams_contexts)
            del content["Teams"]
            ssm_parameter_name = context.ssm_parameter_name
        elif isinstance(context, FoundationContext):
            content = cast(Dict[str, Any],
                           FoundationContext.Schema().dump(context))
            ssm_parameter_name = cast(str, context.ssm_parameter_name)
        else:
            raise ValueError("Unknown 'context' Type")

        ssm.put_parameter(name=ssm_parameter_name, obj=content)
Beispiel #2
0
    def dump_manifest_to_ssm(manifest: T) -> None:
        _logger.debug("Writing manifest to SSM parameter.")

        if isinstance(manifest, Manifest):
            _logger.debug("Teams: %s", [t.name for t in manifest.teams])
            content: Dict[str, Any] = cast(Dict[str, Any],
                                           Manifest.Schema().dump(manifest))
            ssm.cleanup_manifest(env_name=manifest.name)
            if "Teams" in content:
                for team in content["Teams"]:
                    team_parameter_name: str = f"/orbit/{manifest.name}/teams/{team['Name']}/manifest"
                    ssm.put_parameter(name=team_parameter_name, obj=team)
                del content["Teams"]
            manifest_parameter_name = manifest.ssm_parameter_name
        elif isinstance(manifest, FoundationManifest):
            content = cast(Dict[str, Any],
                           FoundationManifest.Schema().dump(manifest))
            ssm.cleanup_manifest(env_name=manifest.name, top_level="orbit-f")
            manifest_parameter_name = manifest.ssm_parameter_name
        else:
            raise ValueError("Unknown 'manifest' Type")

        ssm.put_parameter(name=cast(str, manifest_parameter_name), obj=content)
Beispiel #3
0
def dump_changeset_to_ssm(env_name: str, changeset: Changeset) -> None:
    _logger.debug("Writing changeset to SSM parameter.")
    manifest_parameter_name: str = f"/orbit/{env_name}/changeset"
    ssm.put_parameter(name=manifest_parameter_name, obj=Changeset.Schema().dump(changeset))