Am i missing something ? it seems that you can use --profile with almost any other aws cli functionality.
is there any other way around this then by manually running aws configure ?
update Lambda environment variables from JSON file
aws lambda update-function-configuration --profile mfa --function-name test-api --cli-input-json file://dev.json
Related
I have an AWS Cognito user pool enabled with a PreSignup lambda trigger. For some reason, I need to remove the trigger using aws cognito-idp cli. I am aware with the below command we can set new/update a lambda function ARN, but how can I set to none or delete the existing one. With the new and old AWS console, I can easily manage such action but the requirement is to do it through AWS CLI
aws cognito-idp update-user-pool --user-pool-id=eu-west-1_xxXXXxxyy --lambda-config PreSignUp="<lambda-function-arn>:<function_name>:<function_alias>" --region eu-west-1
Thanks in advance
Use this command, I tested in my lab and it works (replace "YOUR_USER_POOL_ID" with your user pool ID):
aws cognito-idp update-user-pool --user-pool-id YOUR_USER_POOL_ID --lambda-config {}
I have created an API Gateway in AWS using the UI, I want to automate this process and write a shell script which will create the API Gateway, same as I have configured it in AWS.
As already suggested, I also recommend using better tools such as cloudformation to manage the infrastructure.
If you really want to use bash script, you can use AWS Cli commands in your bash script.
create API
aws apigateway create-rest-api --name my-api
get root resource
API=bs8fqo6bp0
aws apigateway get-resources --rest-api-id $API
create resource
aws apigateway create-resource --rest-api-id $API --path-part test \
--parent-id e8kitthgdb
here is an example from AWS docs, https://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-https-example.html
I want to create a lamba deployment package in python (with dependencies) using the Amazon tutorial.
When I push the .zip package with
aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip
I get the following error
An error occurred (AccessDeniedException) when calling the UpdateFunctionCode operation:
User: arn:aws:iam::<ACCOUNT-ID>:user/jeanclaude is not authorized to perform: lambda:UpdateFunctionCode
on resource: arn:aws:lambda:eu-west-3:<ACCOUNT-ID>:function:my-function
Which policy should I grant to jeanclaude to give him the correct access?
The User created in AWS IAM which is configured with your AWS CLI using access_key and secret_key should have enough privileges to interact with AWS Lambda.
I would prefer AWSLambdaFullAccess policy attached to your User/Role. This is just for testing purpose and later you can reduce the privileges if you want.
Once you have done the above then if you run the command
aws lambda update-function-code --function-name "helloworld" --zip-file "fileb://./helloworld.zip" --region "eu-west-2"
it should work, note that for update-function-code mandatory field is just the --function-name other fields are optional.aws cli update-fuction-code
Also please take a note of the create-function command it has just the following fields as mandatory and all other are optional aws cli docs
create-function
--function-name <value>
--runtime <value>
--role <value>
--handler <value>
and the --role here is the role required by the lambda while executing to interact with other services (not to be confused by the user above)
The user needs permission to UpdateFunctionCode for that ARN. More specific information is here.
Basically, I want to know if I can configure everything you see in this image from the AWS CLI. It seems like I can't.
Can I modify this Lambda config to provide an S3 link and function handler all from the CLI?
Yes, using the create-function call.
aws lambda create-function \
--runtime python3.6 \
--handler file_name.lambda_handler \
--code S3Bucket=mybucket,S3Key=path/to/object.zip
I'm trying to update my lambda function code with jar from my local machine via AWS CLI.
The aws lambda has commands to update function code for zip file but not for jar.
I can upload by using s3 bucket, but I need to update from local itself.
I know following are the way to update from S3 bucket and for zip:
aws lambda update-function-code --function-name
--s3-bucket --s3-key
aws lambda update-function-code --function-name
--zip-file "fileb://"
I want to ask is there similar command exist for uploading jar as well?
You're probably missing the "fileb://" part for the jar.
aws lambda update-function-code --function-name my-lambda-name --zip-file fileb://./target/my-lambda-jar.1.0-SNAPSHOT.jar
run this command:
aws lambda update-function-code --function-name my-lambda-name --zip-file fileb://./target/my-lambda-jar.1.0-SNAPSHOT.jar