user3454396
user3454396

Reputation: 423

Terraform and ElasticBeanstalk. How do I mount a EFS in EC2 when EC2 is spun up by elasticbeanstalk?

In short, we are using Terraform to manage our elasticbeanstalk environments. I need the ec2 being spun up by elasticbeanstalk to mount our EFS as well as subsequent EC2 must mount the same EFS when they are spun up by elasticbeanstalk.

I pursued the option of remote-exec, but cannot figure out how to use it in elasticbeanstalk. It seems I required an aws_instance to target the EC2 to execute the mount commands. This I do not have since beanstalk does that for me. None of the elasticbeanstalk settings I could find allows for mounting of an EFS or executing remote code in the EC2 either.

I was also searching for a potential config file solution where I can specify the mountings but no luck.

Can anyone point me in the right direction as to how to solve this issue?

Upvotes: 1

Views: 374

Answers (1)

Marcin
Marcin

Reputation: 238467

You don't use TF for that directly. Instead, you should use .ebextensions for your application. Thus you would have to add .ebextensions to your application and provide code (bash script) that executes the mount operation, e.g. in container_commands.

Upvotes: 1

Related Questions