Im trying to create an IAM role with bash in ubuntu following this tutorial to create a lambdaless data api with aws. However im struggling to create the IAM role through the bash script.
#!/bin/sh . ./common-variables.sh #Setup API Gateway Role role_name=api-gateway-dynamo-full-user-comments aws iam create-role --role-name ${role_name} \ --assume-role-policy-document file://../../IAM/assume-role-api-gateway.json --profile $profile #Add Policy for API Gateway to write to logs role_policy_arn="arn:aws:iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" aws iam attach-role-policy \ --role-name "${role_name}" \ --policy-arn "${role_policy_arn}" --profile ${profile} #Create DynamoDB Policy policy_name="dynamo-full-user-visits-api" aws iam create-policy --policy-name ${policy_name} --policy-document file://../../IAM/dynamo-full-user-comments.json --profile ${profile} #Attach Policy for API Gateway to access DynamoDB role_policy_arn="arn:aws:iam::${aws_account_id}:policy/${policy_name}" aws iam attach-role-policy \ --role-name "${role_name}" \ --policy-arn "${role_policy_arn}" --profile ${profile} Which returns the error:
aws: error: argument --profile: expected one argument usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters] The two changes I made were:
. ./common-variables.sh->common-variables.sh
aws iam create-policy --policy-name ${policy_name} --policy-document file://../../IAM/dynamo-full-user-comments.json --profile ${profile}
-> aws iam create-policy --policy-name ${policy_name} --policy-document file:IAM/dynamo-full-user-comments.json --profile ${profile}
The changes I made were because I have the common variables file in the same directory as this script.