EFS
create-efs-stack.yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ClusterName:
Description: The name of the cluster
Type: String
Region:
Description: The AWS region to create the resources in
Type: String
Default: ap-southeast-1
AllowedValues:
- us-east-1
- us-west-1
- us-west-2
- eu-west-1
- eu-central-1
- ap-southeast-1
- ap-southeast-2
- ap-northeast-1
- ap-northeast-2
- sa-east-1
VpcId:
Description: The VPC ID where the EFS and mount targets will be created
Type: String
PrivateSubnet1:
Description: The first private subnet ID for the EFS mount target
Type: String
PrivateSubnet2:
Description: The second private subnet ID for the EFS mount target
Type: String
PrivateSubnet3:
Description: The third private subnet ID for the EFS mount target
Type: String
ClusterSecurityGroup:
Description: The security group ID of the EKS cluster nodes
Type: String
Resources:
MyEfsFileSystem:
Type: 'AWS::EFS::FileSystem'
Properties:
PerformanceMode: 'generalPurpose'
ThroughputMode: 'elastic'
BackupPolicy:
Status: 'ENABLED'
LifecyclePolicies:
- TransitionToIA: 'AFTER_30_DAYS'
Encrypted: true
FileSystemTags:
- Key: Name
Value: !Sub "${ClusterName}-cluster-efs"
- Key: elasticfilesystem-default-backup
Value: enabled
EfsSecurityGroup:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Enable NFS access
VpcId: !Ref VpcId
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 2049
ToPort: 2049
SourceSecurityGroupId: !Ref ClusterSecurityGroup
SecurityGroupEgress:
- IpProtocol: -1
FromPort: -1
ToPort: -1
CidrIp: 0.0.0.0/0
MountTarget1:
Type: 'AWS::EFS::MountTarget'
Properties:
FileSystemId: !Ref MyEfsFileSystem
SubnetId: !Ref PrivateSubnet1
SecurityGroups:
- !Ref EfsSecurityGroup
DependsOn: EfsSecurityGroup
MountTarget2:
Type: 'AWS::EFS::MountTarget'
Properties:
FileSystemId: !Ref MyEfsFileSystem
SubnetId: !Ref PrivateSubnet2
SecurityGroups:
- !Ref EfsSecurityGroup
DependsOn: EfsSecurityGroup
MountTarget3:
Type: 'AWS::EFS::MountTarget'
Properties:
FileSystemId: !Ref MyEfsFileSystem
SubnetId: !Ref PrivateSubnet3
SecurityGroups:
- !Ref EfsSecurityGroup
DependsOn: EfsSecurityGroup
Outputs:
FileSystemId:
Description: 'The ID of the EFS file system'
Value: !Ref MyEfsFileSystem
Export:
Name: EfsFileSystemId변수 할당 및 프라이빗 서브넷 ID 조회 및 환경 변수에 저장 (최대 3개 프라이빗 서브넷)
변수 값 확인
EFS stack 생성
생성된 EFS 의 ID를 가져와 환경변수에 저장
efs-policy
eks-values/aws/efs
Last updated
Was this helpful?