'Problem Mounting EFS through .ebextensions on EB using Linux 2
We have a .war, containing an .ebextensions folder with the storage-efs-mountfilesystem.config, which mounts the efs to the EC2 Instance. On Linux 1 it works like a charm. Now we use the same war on Linux 2 and cannot deploy it, as we get an error which says command execution failed. We got the .config from AWS' developer Guide so we dont know if it just is not updated for Linux 2 or we have to change something, not mentioned on the docs?
Here are the logs:
2022-03-25 09:43:56,732 [ERROR] Command 01_mount (/tmp/mount-efs.sh) failed
2022-03-25 09:43:56,732 [ERROR] Error encountered during build of prebuild_0_Kiwi: Command
01_mount failed
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 576, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 276, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 01_mount failed
2022-03-25 09:43:56,733 [ERROR] -----------------------BUILD FAILED!------------------------
2022-03-25 09:43:56,733 [ERROR] Unhandled exception during build: Command 01_mount failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 176, in
worklog.build(metadata, configSets)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 137, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 564, in build
self.run_config(config, worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 576, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 276, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 01_mount failed
Solution 1:[1]
For me this did helped create a config file which is executed before the mount file:
option_settings:
aws:elasticbeanstalk:application:environment:
MOUNT_UID: 3984
MOUNT_GID: 3984
To Create the filesystem I used this configuration (Which adds a accesspoint) and configures access from the VPC group
option_settings:
aws:elasticbeanstalk:customoption:
VPCId: "vpc-00000000000000000"
VpcDefaultGroupId: 'sg-00000000000000000'
## Subnet Options
SubnetA: "subnet-00000000000000000"
SubnetB: "subnet-00000000000000000"
SubnetC: "subnet-00000000000000000"
Resources:
FileSystem:
Type: AWS::EFS::FileSystem
Properties:
FileSystemTags:
- Key: Name
Value: "EB-EFS-FileSystem"
PerformanceMode: "generalPurpose"
Encrypted: "false"
# KmsKeyId: "KMS-key-ARN"
AccessPoint:
Type: AWS::EFS::AccessPoint
Properties:
AccessPointTags:
- Key: Name
Value: "EB-EFS-AccessPoint"
FileSystemId: {Ref: FileSystem}
## Mount Target Resources
MountTargetA:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: {Ref: FileSystem}
SecurityGroups:
- {Ref: MountTargetSecurityGroup}
SubnetId:
Fn::GetOptionSetting: {OptionName: SubnetA}
MountTargetB:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: {Ref: FileSystem}
SecurityGroups:
- {Ref: MountTargetSecurityGroup}
SubnetId:
Fn::GetOptionSetting: {OptionName: SubnetB}
MountTargetC:
Type: AWS::EFS::MountTarget
Properties:
FileSystemId: {Ref: FileSystem}
SecurityGroups:
- {Ref: MountTargetSecurityGroup}
SubnetId:
Fn::GetOptionSetting: {OptionName: SubnetC}
##############################################
#### Do not modify values below this line ####
##############################################
MountTargetSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for mount target
SecurityGroupIngress:
- FromPort: '2049'
IpProtocol: tcp
SourceSecurityGroupId:
Fn::GetAtt: [AWSEBSecurityGroup, GroupId]
ToPort: '2049'
- FromPort: '2049'
IpProtocol: tcp
SourceSecurityGroupId:
Fn::GetOptionSetting: {OptionName: VpcDefaultGroupId}
ToPort: '2049'
VpcId:
Fn::GetOptionSetting: {OptionName: VPCId}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |