无法在ubuntu上使用bash创建IAM角色

时间:2019-08-03 02:46:03

标签: bash amazon-web-services terminal amazon-iam

在本教程之后,我尝试用ubuntu中的bash创建IAM角色,以使用aws创建无lambdaless数据api。但是,我很难通过bash脚本创建IAM角色。

https://hackernoon.com/serverless-and-lambdaless-scalable-crud-data-api-with-aws-api-gateway-and-dynamodb-626161008bb2

#!/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}

哪个返回错误:

aws: error: argument --profile: expected one argument
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]

我所做的两个更改是:

. ./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}

之所以进行更改,是因为我在与该脚本相同的目录中拥有公共变量文件。

1 个答案:

答案 0 :(得分:1)

您的library(tidyverse) df %>% gather(col, val, -ID) %>% filter(val == 1) %>% arrange(ID, col) %>% # optional, just to sort select(-val) # optional, just to remove col of 1's ID col 1 a1 flag1 2 a1 flag3 3 a1 flag4 4 a2 flag2 5 a2 flag3 6 a2 flag4 变量未正确定义。它以空字符串形式求值。尝试在脚本顶部回显该值以进行确认。