下記はEC2起動時にwww-dataユーザで/var/www/ec2_userdata.shスクリプトを実行するスクリプト
Userdataを実行するのはユーザ指定をしないとrootで実行されるので注意
Content-Type: multipart /mixed ; boundary= "//" MIME-Version: 1.0 -- // Content-Type: text /cloud-config ; charset= "us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename= "cloud-config.txt" #cloud-config cloud_final_modules: - [scripts-user, always] -- // Content-Type: text /x-shellscript ; charset= "us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename= "userdata.txt" #!/bin/bash su www-data -s /var/www/ec2_userdata .sh |