我想自动安装EFS
到我EC2 instance
使用的 AWS CDK。
我创建了文件系统:
self.file_system = efs.FileSystem(
scope=self,
id="Efs",
vpc=self.vpc,
file_system_name="EFS",
removal_policy=RemovalPolicy.DESTROY,
)
Run Code Online (Sandbox Code Playgroud)
和 EC2 实例:
self.ec2_instance = ec2.Instance(
scope=self,
id="ec2Instance",
instance_name="my_ec2_instance",
instance_type=ec2.InstanceType.of(
instance_class=ec2.InstanceClass.BURSTABLE2,
instance_size=ec2.InstanceSize.MICRO,
),
machine_image=ec2.AmazonLinuxImage(
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX_2
),
vpc=self.vpc,
vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PUBLIC),
key_name="ec2-key-pair",
security_group=ec2_security_group,
)
Run Code Online (Sandbox Code Playgroud)
现在我需要做什么才能将它们连接起来?我看到很多在控制台上执行此操作的示例,但到目前为止我还没有找到在 AWS CDK 中执行此操作的方法。