0

I am trying to run the following command on an EC2 instance I manage.

sudo aws secretsmanager get-secret-value --secret-id "KingsKidzApplication-env" --region "ap-southeast-2" | jq -r '.SecretString' | jq -r "to_entries|map(\"\(.key)=\\\"\(.value|tostring)\\\"\")|.[]" > "/srv/kingskidz/.env"

However I get the message -bash: /srv/kingskidz/.env: Permission denied

It does not create the .env file. What am I doing wrong here? I have sudo writes for the server. I have given the ec2 AMI role the full permission for secret manager.

enter image description here

Mark B
  • 183,023
  • 24
  • 297
  • 295
Harlan Gray
  • 341
  • 6
  • 20
  • It is saying you don't have permission to the `/srv/kingskidz/.env` file. It has nothing to do with AWS IAM permissions/roles. – Mark B Jun 14 '23 at 19:08
  • yes, but why? I am using sudo. – Harlan Gray Jun 15 '23 at 02:36
  • You have multiple commands piped into each other. Only the first of those commands is running as root. https://stackoverflow.com/questions/40292676/pipe-command-with-sudo – Mark B Jun 15 '23 at 12:13

0 Answers0