我已经在两个可用区中启动了两个ec2实例,我需要使用terraform在两个实例中安装ef。
resource "aws_efs_file_system" "magento-efs" {
creation_token = "efs-demo"
performance_mode = "generalPurpose"
throughput_mode = "bursting"
encrypted = "true"
tags = {
Name = "Magento-EFS"
}
}
resource "aws_efs_mount_target" "efs-mount" {
file_system_id = "${aws_efs_file_system.magento-efs.id}"
subnet_id = "${aws_subnet.public_subnet.0.id}"
security_groups = ["${aws_security_group.efs-sg.id}"]
}
使用上述代码,我可以在us-east-1a中创建efs。我需要同时在us-east-1a和us-east-1b中提供
答案 0 :(得分:3)
您只需要在AZ us-east-1b的子网中添加另一个安装目标:
git merge
更优雅(使用resource "aws_efs_mount_target" "efs-mount-b" {
file_system_id = "${aws_efs_file_system.magento-efs.id}"
subnet_id = "${aws_subnet.public_subnet.1.id}"
security_groups = ["${aws_security_group.efs-sg.id}"]
}
取决于子网数):
count
答案 1 :(得分:0)
我使用 terraform 版本 0.14.10
。这会奏效。
resource "aws_efs_mount_target" "efs-mount-a" {
file_system_id = aws_efs_file_system.magento-efs.id
subnet_id = aws_subnet.public_subnet.0.id
security_groups = [aws_security_group.efs-sg.id]
}
resource "aws_efs_mount_target" "efs-mount-b" {
file_system_id = aws_efs_file_system.magento-efs.id
subnet_id = aws_subnet.public_subnet.1.id
security_groups = [aws_security_group.efs-sg.id]
}