CDK를 사용한 Fargate + EFS 권한
단일 AZ로 나를 판단하지 마십시오. Fargate에서 단일 작업을 실행 중이며 하나의 인스턴스만 필요합니다.
const {vpc, az, region, account} = props;
const fileSystem = new FileSystem(this, 'Efs', {
vpc,
performanceMode: PerformanceMode.GENERAL_PURPOSE,
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
onePerAz: true,
availabilityZones: [az]
}
});
const accessPoint = new AccessPoint(this, 'AccessPoint', {
fileSystem: fileSystem,
});
const task = new ecs.FargateTaskDefinition(this, 'Task', {
cpu: 256,
memoryLimitMiB: 512
});
const volumeName = 'efs-volume';
task.addVolume({
name: volumeName,
efsVolumeConfiguration: {
fileSystemId: fileSystem.fileSystemId,
transitEncryption: 'ENABLED',
authorizationConfig:{
accessPointId: accessPoint.accessPointId,
iam: 'ENABLED'
}
}
});
const container = task.addContainer('Container', {
image: ecs.ContainerImage.fromAsset('./container'),
portMappings: [{hostPort: 80, containerPort: 80}],
});
container.addMountPoints({
containerPath: '/mount/data',
sourceVolume: volumeName,
readOnly: false
});
task.addToTaskRolePolicy(
new iam.PolicyStatement({
actions: [
'elasticfilesystem:ClientRootAccess',
'elasticfilesystem:ClientWrite',
'elasticfilesystem:ClientMount',
'elasticfilesystem:DescribeMountTargets'
],
resources: [`arn:aws:elasticfilesystem:${region}:${account}:file-system/${fileSystem.fileSystemId}`]
})
);
task.addToTaskRolePolicy(
new iam.PolicyStatement({
actions: ['ec2:DescribeAvailabilityZones'],
resources: ['*']
})
);
나는 이것이 누군가의 두통을 덜어주기를 바랍니다!
Originally posted on my blog
Reference
이 문제에 관하여(CDK를 사용한 Fargate + EFS 권한), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/ibliskavka/fargate-with-efs-cdk-9ep텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)