File tree Expand file tree Collapse file tree 7 files changed +45
-2
lines changed
Expand file tree Collapse file tree 7 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -26,12 +26,14 @@ locals {
2626 service_min = 1
2727 service_max = 10
2828 httpport = var.httpport
29+ readonly = ! var.write_to_container
2930 } : {
3031 cpu = 256
3132 memory = 512
3233 service_min = 1
3334 service_max = 2
3435 httpport = var.httpport
36+ readonly = ! var.write_to_container
3537 }
3638 db_username = " ${ var . environment } _${ var . app } "
3739 db_database = " ${ var . environment } _${ var . app } "
Original file line number Diff line number Diff line change @@ -145,4 +145,10 @@ variable "domain_base" {
145145 description = " base domain of the application"
146146 type = string
147147 default = " "
148+ }
149+
150+ variable "write_to_container" {
151+ description = " whether applications can write to the container file system"
152+ type = bool
153+ default = false
148154}
Original file line number Diff line number Diff line change @@ -289,6 +289,7 @@ type Config struct {
289289 Buckets []Bucket `json:"buckets"`
290290 Secrets []Secret `json:"secrets"`
291291 Tables []Table `json:"tables"`
292+ WriteToContainer bool `json:"writeToContainer"`
292293}
293294
294295func (c Config ) Version () string {
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ module "app" {
5555 did_env_var = " {{.DIDEnvVar}}" {{end}}
5656 app = var.app
5757 appState = var.app
58+ write_to_container = {{.WriteToContainer}}
5859 environment = terraform.workspace
5960 # if there are any env vars you want available only to your container
6061 # in the vpc as opposed to set in the dockerfile, enter them here
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "context"
5+
6+ "github.com/urfave/cli/v3"
7+ )
8+
9+ var writeToContainerCmd = & cli.Command {
10+ Name : "write-to-container" ,
11+ Usage : "modify write-to-container settings" ,
12+ Commands : []* cli.Command {
13+ writeToContainerOnCmd ,
14+ writeToContainerOffCmd ,
15+ },
16+ }
17+
18+ var writeToContainerOnCmd = & cli.Command {
19+ Name : "on" ,
20+ Action : modifyAndRegenerate (func (ctx context.Context , cmd * cli.Command , c * Config ) error {
21+ c .WriteToContainer = true
22+ return nil
23+ }),
24+ }
25+
26+ var writeToContainerOffCmd = & cli.Command {
27+ Name : "off" ,
28+ Action : modifyAndRegenerate (func (ctx context.Context , cmd * cli.Command , c * Config ) error {
29+ c .WriteToContainer = false
30+ return nil
31+ }),
32+ }
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ resource "aws_ecs_task_definition" "app" {
2020 cpu = var.config.cpu
2121 memory = var.config.memory
2222 essential = true
23- readonlyRootFilesystem = true
23+ readonlyRootFilesystem = var.config.readonly
2424 portMappings = [
2525 {
2626 containerPort = var.config.httpport
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ variable "config" {
8383 service_min = number
8484 service_max = number
8585 httpport = number
86+ readonly = bool
8687 })
8788}
8889
@@ -184,4 +185,4 @@ variable "db_config" {
184185 username = string
185186 database = string
186187 })
187- }
188+ }
You can’t perform that action at this time.
0 commit comments