AWS-Command
Configure aws credential
aws configure
aws iam get-user
Create a bucket:
aws s3 mb s3://bucketname
Get a java function:
sam init --location gh:symphoniacloud/sam-init-HelloWorldLambdaJava
sam init --location gh:symphoniacloud/sam-init-HelloWorldLambdaJava-zip
Deploy in AWS Lambda:
sam deploy --s3-bucket $CF_BUCKET --stack-name HelloWorldLambdaJava --capabilities CAPABILITY_IAM
Inovke lambda function
aws lambda invoke --invocation-type RequestResponse --function-name HelloWorldJava --payload \"world\" outputfile.txt
Invoke lambda function with invocation type
aws lambda invoke --invocation-type Event --function-name HelloWorldJava --payload \"world\" outputfile.txt
Delete the lambda:
aws cloudformation delete-stack --stack-name HelloWorldLambda
aws cloudformation delete-stack --stack-name HelloWorldLambda
View the cloudformation of particular stack:
aws cloudformation list-stack-resources --stack-name chapter4-sam
View the format of input or output in aws services(in this case s3):
sam local generate-event s3 delete
View bucket name:
aws cloudformation describe-stack-resource --stack-name chapter-five --logical-resource-id PipelineStartBucket --query 'StackResourceDetail.PhysicalResourceId'
The underline commands, chapter-five is the stack name and PipelineStartBucket is the bucket logical name. Result will be similar like:
chapter-five-781251715253-us-west-2-start
Upload file to s3 bucket:
aws s3 cp sampledata.json s3://chapter-five-781251715253-us-west-2-start/sampledata.json
Serverless
Install serverless:
sudo npm install -g serverless
Enter credentials:
sls config credentials --provider aws --profile serverlessUser --key <your user key> --secret <your secret key>
Install nvm(node version manager):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Serverless version:
sls -v
template.yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: Testing
Resources:
HelloWorldLambda:
Type: AWS::Serverless::Function
Properties:
FunctionName: HelloWorldJava
Runtime: java8
MemorySize: 512
Timeout: 2
Handler: book.EnvVarLambda::handler
CodeUri: target/lambda.jar
Environment:
Varibales:
DATABASE_URL: my-database-url
Error 1:
java.lang.ClassNotFoundException: com.fasterxml.jackson.core.StreamReadCapability
This is due to missing jackson core dependency.
Error 2:
java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map java.util.Collections$UnmodifiableMap.m accessible
This is due to incompatable version of java with maven plugin.
Seems like an version incompatibility between the cucumber version and the Java version you are running. It would be helpful if you provided us with both versions
Error 3:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.DeserializationContext.isEnabled
This is because of the version difference in jackson databind, core ...
Error 4:
The specified log group does not exist. (Service: AWSLogs; Status :400; Error Code....)
I don't know the reason, but the variable subsitution for cloud log group in template.yaml is not working.
Manually created the log group in cloud formation.
Error 5:
Aws resources not found in cloud9.
This has been replaced by IDE AWS toolkit, so it won't be shown in the cloud 9. If you want to see it, got to perference, disable aws toolkit in AWS Resources.
Comments
Post a Comment