Skip to content

Commit

Permalink
fix: allow efs volumes to have multiple mount points in a single serv…
Browse files Browse the repository at this point in the history
…ice (#5631)

This is the easiest possible fix for the issue, we got an internal ticket requesting a fix for this so I wanted to get a basic fix out for review first and iterate if this causes issues.

Related #2921 



By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
  • Loading branch information
CaptainCarpensir committed Jan 23, 2024
1 parent e277979 commit c3e4249
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ storage:
path: '/etc/mount1'
efs:
id:
from_cfn: stack-fs-12345
from_cfn: stack-fs-12345
externalEFSVolume2:
path: '/etc/mount2'
efs:
id:
from_cfn: stack-fs-12345

# Optional fields for more advanced use-cases.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ Metadata:
path: '/etc/mount1'
efs:
id:
from_cfn: stack-fs-12345
from_cfn: stack-fs-12345
externalEFSVolume2:
path: '/etc/mount2'
efs:
id:
from_cfn: stack-fs-12345
# Optional fields for more advanced use-cases.
#
Expand Down Expand Up @@ -190,7 +195,7 @@ Resources:
yourtopicyourtopicfifoURL: !Ref yourtopicyourtopicfifoEventsQueue
nonfifotopicnonfifotopicURL: !Ref nonfifotopicnonfifotopicEventsQueue
- Name: COPILOT_MOUNT_POINTS
Value: '{"externalEFSVolume":"/etc/mount1"}'
Value: '{"externalEFSVolume":"/etc/mount1","externalEFSVolume2":"/etc/mount2"}'
EnvironmentFiles:
- !If
- HasEnvFile
Expand All @@ -207,6 +212,9 @@ Resources:
- ContainerPath: '/etc/mount1'
ReadOnly: true
SourceVolume: externalEFSVolume
- ContainerPath: '/etc/mount2'
ReadOnly: true
SourceVolume: externalEFSVolume2
Volumes:
- Name: externalEFSVolume
EFSVolumeConfiguration:
Expand All @@ -215,6 +223,13 @@ Resources:
TransitEncryption: ENABLED
AuthorizationConfig:
IAM: DISABLED
- Name: externalEFSVolume2
EFSVolumeConfiguration:
FilesystemId: !ImportValue 'stack-fs-12345'
RootDirectory: '/'
TransitEncryption: ENABLED
AuthorizationConfig:
IAM: DISABLED
ExecutionRole:
Metadata:
'aws:copilot:description': 'An IAM Role for the Fargate agent to make AWS API calls on your behalf'
Expand Down Expand Up @@ -319,7 +334,16 @@ Resources:
- Effect: 'Allow'
Action: ["logs:CreateLogStream", "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:PutLogEvents"]
Resource: "*"
- PolicyName: !Join ['', ['GrantEFSAccess', !ImportValue 'stack-fs-12345']]
- PolicyName: !Join ['', ['GrantEFSAccess', !ImportValue 'stack-fs-12345', '-0']]
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: 'Allow'
Action:
- 'elasticfilesystem:ClientMount'
Resource:
- !Join ['/', [!Sub 'arn:${AWS::Partition}:elasticfilesystem:${AWS::Region}:${AWS::AccountId}:file-system', !ImportValue 'stack-fs-12345']]
- PolicyName: !Join ['', ['GrantEFSAccess', !ImportValue 'stack-fs-12345', '-1']]
PolicyDocument:
Version: '2012-10-17'
Statement:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ TaskRole:
Resource: "*"
{{- end }}
{{- if .Storage}}
{{- range $EFS := .Storage.EFSPerms}}
{{- range $i, $EFS := .Storage.EFSPerms}}
{{- if not $EFS.FilesystemID.RequiresImport}}
- PolicyName: 'GrantEFSAccess{{$EFS.FilesystemID.Value}}'
- PolicyName: 'GrantEFSAccess{{$EFS.FilesystemID.Value}}-{{$i}}'
{{- else}}
- PolicyName: !Join ['',[ 'GrantEFSAccess', !ImportValue {{$EFS.FilesystemID.Value}}]]
- PolicyName: !Join ['',[ 'GrantEFSAccess', !ImportValue {{$EFS.FilesystemID.Value}}, '-{{$i}}']]
{{- end}}
PolicyDocument:
Version: '2012-10-17'
Expand Down

0 comments on commit c3e4249

Please sign in to comment.