Skip to content

Commit

Permalink
feat: use Lambda aarch64 architecture as default for CodeBuild (#132)
Browse files Browse the repository at this point in the history
* feat: use Lambda aarch64 architecture as default for CodeBuild

* removed custom python installation
  • Loading branch information
moritzzimmer authored Jan 15, 2024
1 parent d671915 commit 6e28bb9
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ for example.
| <a name="input_capacity_provider_strategy"></a> [capacity\_provider\_strategy](#input\_capacity\_provider\_strategy) | Capacity provider strategies to use for the service. Can be one or more. | <pre>list(object({<br> capacity_provider = string<br> weight = string<br> base = optional(string, null)<br> }))</pre> | `null` | no |
| <a name="input_cloudwatch_logs"></a> [cloudwatch\_logs](#input\_cloudwatch\_logs) | CloudWatch logs configuration for the containers of this service. CloudWatch logs will be used as the default log configuration if Firelens is disabled and for the fluentbit and otel containers. | <pre>object({<br> enabled = optional(bool, true)<br> name = optional(string, "")<br> retention_in_days = optional(number, 7)<br> })</pre> | `{}` | no |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | The ECS cluster id that should run this service | `string` | n/a | yes |
| <a name="input_code_build_environment_compute_type"></a> [code\_build\_environment\_compute\_type](#input\_code\_build\_environment\_compute\_type) | Information about the compute resources the CodeBuild stage of the deployment pipeline will use. | `string` | `"BUILD_LAMBDA_1GB"` | no |
| <a name="input_code_build_environment_image"></a> [code\_build\_environment\_image](#input\_code\_build\_environment\_image) | Docker image to use for the CodeBuild stage of the deployment pipeline. The image needs to include python. | `string` | `"aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.12"` | no |
| <a name="input_code_build_environment_type"></a> [code\_build\_environment\_type](#input\_code\_build\_environment\_type) | Type of build environment for the CodeBuild stage of the deployment pipeline. | `string` | `"ARM_LAMBDA_CONTAINER"` | no |
| <a name="input_code_build_log_retention_in_days"></a> [code\_build\_log\_retention\_in\_days](#input\_code\_build\_log\_retention\_in\_days) | Log retention in days of the CodeBuild CloudWatch log group. | `number` | `7` | no |
| <a name="input_code_build_role_name"></a> [code\_build\_role\_name](#input\_code\_build\_role\_name) | Use an existing role for codebuild permissions that can be reused for multiple services. Otherwise a separate role for this service will be created. | `string` | `""` | no |
| <a name="input_code_pipeline_artifact_bucket"></a> [code\_pipeline\_artifact\_bucket](#input\_code\_pipeline\_artifact\_bucket) | Use an existing bucket for codepipeline artifacts that can be reused for multiple services. Otherwise a separate bucket for each service will be created. | `string` | `""` | no |
Expand Down
3 changes: 3 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ module "code_deploy" {

cluster_name = var.cluster_id
container_name = local.container_name
code_build_environment_compute_type = var.code_build_environment_compute_type
code_build_environment_image = var.code_build_environment_image
code_build_environment_type = var.code_build_environment_type
codestar_notifications_detail_type = var.codestar_notifications_detail_type
codestar_notifications_event_type_ids = var.codestar_notifications_event_type_ids
codestar_notifications_target_arn = var.codestar_notifications_target_arn
Expand Down
2 changes: 1 addition & 1 deletion modules/deployment/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.9"
version = ">= 5.32"
}
}
}
9 changes: 3 additions & 6 deletions modules/deployment/code_build.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ resource "aws_codebuild_project" "this" {
}

environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/amazonlinux2-x86_64-standard:4.0"
type = "LINUX_CONTAINER"
compute_type = var.code_build_environment_compute_type
image = var.code_build_environment_image
type = var.code_build_environment_type

environment_variable {
name = "CONTAINER_NAME"
Expand All @@ -49,9 +49,6 @@ resource "aws_codebuild_project" "this" {
version: 0.2
phases:
install:
runtime-versions:
python: 3.9
build:
commands:
- |
Expand Down
18 changes: 18 additions & 0 deletions modules/deployment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ variable "code_pipeline_role" {
type = string
}

variable "code_build_environment_compute_type" {
description = "Information about the compute resources the CodeBuild stage of the deployment pipeline will use."
default = "BUILD_LAMBDA_1GB"
type = string
}

variable "code_build_environment_image" {
description = "Docker image to use for the CodeBuild stage of the deployment pipeline. The image needs to include python."
default = "aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.12"
type = string
}

variable "code_build_environment_type" {
description = "Type of build environment for the CodeBuild stage of the deployment pipeline."
default = "ARM_LAMBDA_CONTAINER"
type = string
}

variable "code_build_role" {
default = ""
description = "Use an existing role for codebuild permissions that can be reused for multiple services."
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ variable "code_pipeline_role_name" {
type = string
}

variable "code_build_environment_compute_type" {
description = "Information about the compute resources the CodeBuild stage of the deployment pipeline will use."
default = "BUILD_LAMBDA_1GB"
type = string
}

variable "code_build_environment_image" {
description = "Docker image to use for the CodeBuild stage of the deployment pipeline. The image needs to include python."
default = "aws/codebuild/amazonlinux-aarch64-lambda-standard:python3.12"
type = string
}

variable "code_build_environment_type" {
description = "Type of build environment for the CodeBuild stage of the deployment pipeline."
default = "ARM_LAMBDA_CONTAINER"
type = string
}

variable "code_build_role_name" {
default = ""
description = "Use an existing role for codebuild permissions that can be reused for multiple services. Otherwise a separate role for this service will be created."
Expand Down

0 comments on commit 6e28bb9

Please sign in to comment.