I have this deployments architecture that deploy scalable WordPress using Amazon ECS containers. These are based from official WordPress image; The containers also mount an Amazon EFS file system on /var/www/html/wp-content mainly to host plugins and themes. The reason is because some plugins write files inside the wp-content directories, and I'd like the containers to have access to that files.
There is also bastion EC2 instance host so that I can access the EFS directory to make modifications and sync to locally.
The problem is I couldn't write the EFS directory without sudo-ing as www-data.
$ssh -i private_key.pem ubuntu@$BASTION_HOST
$touch /var/www/html/wp-content/test.txt
touch: cannot touch '/var/www/html/wp-content/test.txt': Permission denied
$sudo -u www-data bash # Access bash as www-data user
$touch /var/www/html/wp-content/test.txt
$ls -al /var/www/html/wp-content/test.txt
-rw-rw-r-- 1 www-data www-data 0 Aug 12 01:08 /var/www/html/wp-content/test.txt
What I want to achieve is that I want to do rsync the plugin in my local development both to and from the wp-content directory.
I tried the command below
rsync -av -e "ssh -i private_key.pem" content/plugins ubuntu@$BASTION_HOST/var/www/html/wp-content
but it failed.
I also tried as www-data, just for sure.
rsync -av -e "ssh -i private_key.pem" content/plugins www-data@$BASTION_HOST:/var/www/html/wp-content
I tried rsync to other directory, though, and it works.
rsync -av -e "ssh -i private_key.pem" content/plugins www-data@$BASTION_HOST:/home/ubuntu/sync
I wanted to change the permission of the /var/www/html/wp-content in the bastion to ubuntu, but the last time I did it, the WordPress containers couldn't write to the NFS directory; so the safest way is to keep the permission intact.
What did I miss?
Update 1
I tried adding ubuntu user into www-data in the bastion server.
$ sudo usermod -aG www-data ubuntu
$ cat /etc/group | grep www-data
www-data:x:33:ubuntu
$ touch /var/www/html/wp-content/test.txt
touch: cannot touch '/var/www/html/wp-content/test.txt': Permission denied
Still doesn't work.
