Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add additional compute types for CodeBuild #462

Closed
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
5 changes: 5 additions & 0 deletions seedfarmer/commands/_module_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def deploy_module(
extra_post_build_commands=["cd module/"] + _phases.post_build.commands + md5_put + metadata_put,
extra_env_vars=env_vars,
codebuild_compute_type=module_manifest.deploy_spec.build_type,
codebuild_environment_type=module_manifest.deploy_spec.environment_type,
codebuild_role_name=module_role_name,
codebuild_image=module_manifest.codebuild_image
if module_manifest.codebuild_image is not None
Expand Down Expand Up @@ -244,6 +245,7 @@ def destroy_module(
extra_post_build_commands=["cd module/"] + _phases.post_build.commands + remove_ssm,
extra_env_vars=env_vars,
codebuild_compute_type=module_manifest.deploy_spec.build_type,
codebuild_environment_type=module_manifest.deploy_spec.environment_type,
codebuild_role_name=module_role_name,
codebuild_image=module_manifest.codebuild_image
if module_manifest.codebuild_image is not None
Expand Down Expand Up @@ -284,6 +286,7 @@ def _execute_module_commands(
extra_post_build_commands: Optional[List[str]] = None,
extra_env_vars: Optional[Dict[str, Any]] = None,
codebuild_compute_type: Optional[str] = None,
codebuild_environment_type: Optional[str] = None,
codebuild_role_name: Optional[str] = None,
codebuild_image: Optional[str] = None,
) -> Tuple[str, Optional[Dict[str, str]]]:
Expand Down Expand Up @@ -313,6 +316,7 @@ def _session_getter() -> Session:
codebuild_image=codebuild_image,
bundle_id=f"{deployment_name}-{group_name}-{module_manifest_name}",
codebuild_compute_type=codebuild_compute_type,
codebuild_environment_type=codebuild_environment_type,
extra_files=extra_file_bundle,
boto3_session=session_getter,
)
Expand All @@ -331,6 +335,7 @@ def _execute_module_commands(
extra_post_build_commands: Optional[List[str]] = None,
extra_env_vars: Optional[Dict[str, Any]] = None,
codebuild_compute_type: Optional[str] = None,
codebuild_environment_type: Optional[str] = None,
) -> str:
deploy_info = {
"aws_region": os.environ.get("AWS_DEFAULT_REGION"),
Expand Down
26 changes: 26 additions & 0 deletions seedfarmer/models/_deploy_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ class BuildType(Enum):
BUILD_GENERAL1_MEDIUM = "BUILD_GENERAL1_MEDIUM"
BUILD_GENERAL1_LARGE = "BUILD_GENERAL1_LARGE"
BUILD_GENERAL1_2XLARGE = "BUILD_GENERAL1_2XLARGE"
BUILD_LAMBDA_1GB = "BUILD_LAMBDA_1GB"
BUILD_LAMBDA_2GB = "BUILD_LAMBDA_2GB"
BUILD_LAMBDA_4GB = "BUILD_LAMBDA_4GB"
BUILD_LAMBDA_8GB = "BUILD_LAMBDA_8GB"
BUILD_LAMBDA_10GB = "BUILD_LAMBDA_10GB"


class EnvironmentType(Enum):
ARM_CONTAINER = "ARM_CONTAINER"
LINUX_CONTAINER = "LINUX_CONTAINER"
LINUX_GPU_CONTAINER = "LINUX_GPU_CONTAINER"
WINDOWS_SERVER_2019_CONTAINER = "WINDOWS_SERVER_2019_CONTAINER"
ARM_LAMBDA_CONTAINER = "ARM_LAMBDA_CONTAINER"
LINUX_LAMBDA_CONTAINER = "LINUX_LAMBDA_CONTAINER"


class BuildPhase(CamelModel):
Expand Down Expand Up @@ -69,12 +83,24 @@ class DeploySpec(CamelModel):
deploy: Optional[ExecutionType] = None
destroy: Optional[ExecutionType] = None
build_type: Optional[str] = None
environment_type: Optional[str] = None
publish_generic_env_variables: Optional[bool] = False

def __init__(self, **data: Any) -> None:
super().__init__(**data)
import logging

_logger: logging.Logger = logging.getLogger(__name__)
_logger.debug("LUCAS DEBUG")
_logger.debug(data.keys())
_logger.debug(data["environment_type"])
if data.get("build_type"):
chk = str(data["build_type"]).upper()
self.build_type = chk if chk in BuildType.__members__.keys() else BuildType.BUILD_GENERAL1_SMALL.value
else:
self.build_type = BuildType.BUILD_GENERAL1_SMALL.value
if data.get("environment_type"):
chk = str(data["environment_type"]).upper()
_logger.debug(f"LUCAS DEBUG: {chk}")
_logger.debug(f"LUCAS DEBUG: {EnvironmentType.__members__.keys()}")
self.environment_type = chk if chk in EnvironmentType.__members__.keys() else None