I am using serverless framework for deploying to AWS. Below is the version:
$ sls --version
Framework Core: 2.64.1 (standalone)
Plugin: 5.5.0
SDK: 4.3.0
Components: 3.17.1
The problem I have is how to let sls skip default value for a variable. Below is my configuration. It has a variable dbStreamArn which will be assigned if there is a command line parameter dbStreamArn, if not it tries to read it from a cloudformation output.
However, when I run sls deploy --dbStreamArn xxxx, I got an error Trying to request a non exported variable from CloudFormation.. It seems that sls tries to get the default value even there is a command line parameter. Is there a way to let sls skip parsing the default value?
custom:
dbStreamArn: ${opt:dbStreamArn, "${cf:dbs-stack.DynamoDBTableEventsSignalStreamArn}"
Related
Here's how I'm instantiating my stack:
new LambdaStack(new App(), 'LambdaStack', {
env: { account: AWS_ACCOUNT_ID, region: 'us-east-1' },
synthesizer: new DefaultStackSynthesizer({
qualifier: 'lambda-stk',
}),
stackName: 'LambdaStack',
});
First I ensure that my ~/.aws/credentials file has the correct credentials. Then I bootstrap:
npx cdk bootstrap --qualifier lambda-stk --toolkit-stack-name LambdaStack aws://ACCOUNT_ID_HERE/us-east-1
Everything looks good in the console. Then, I deploy:
npx cdk deploy --require-approval never
Everything still looks good in the console -- the lambdas have been created as I expected, etc.
Then, I simply run the same deploy command again without changing anything and I get this error:
LambdaStack failed: Error: LambdaStack: SSM parameter /cdk-bootstrap/lambda-stk/version not found. Has the environment been bootstrapped? Please run 'cdk bootstrap' (see https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html)
Upon further investigation, it seems that the bootstrap command properly creates the referenced SSM parameter but then the first deploy command deletes that parameter. Why would it do that and how can I fix this problem?
Fixed it by naming the bootstrap stack something different from LambdaStack. I was under the impression that the bootstrap command was spinning up the stack that the "main" stack would use, but actually it's a completely different stack. So I changed the bootstrap command to:
npx cdk bootstrap --qualifier lambda-stk --toolkit-stack-name LambdaStackCDKToolkit aws://ACCOUNT_ID_HERE/us-east-1
And it worked.
When I try to use SAM cli to invoke my quarkus native function locally as per the tutorial it fails to run with bellow error no such file or directory for /var/task/bootstrap. Function.zip does exist and contain bootstrap, Anyone have any ideas how to solve?
OS: Ubuntu 18 (on VirtualBox)
walter#ubuntu18 brialambda/target $ sam local invoke --template sam.native.yaml --event ../payload.json
Invoking not.used.in.provided.runtime (provided)
Decompressing /home/walter/workspace/walterlambda/target/function.zip
Skip pulling image and use local one: public.ecr.aws/sam/emulation-provided:rapid-1.35.0-x86_64.
Mounting /tmp/tmp41trke88 as /var/task:ro,delegated inside runtime container
START RequestId: ee5e27d8-4bb7-4e0a-8873-f92c48459993 Version: $LATEST
time="2021-11-09T14:15:38.302" level=error msg="Init failed" InvokeID= error="fork/exec /var/task/bootstrap: no such file or directory"
Function 'WalterlambdaNative' timed out after 15 seconds
I've seen that issue when people followed the non-native build process (https://quarkus.io/guides/amazon-lambda#build-and-deploy) but deployed as native. It is important to do the native build (https://quarkus.io/guides/amazon-lambda#deploy-to-aws-lambda-custom-native-runtime) by calling e.g.
./mvnw package -Dnative
or
./gradlew build -Dquarkus.package.type=native
There are two other related posts as well:
Unable to Invoke Quarkus Functions Natively in an AWS Lambda function with MacOS Catalina
Micronaut GraalVM Native Image: Lambda fails with an error "Error: fork/exec /var/task/bootstrap: no such file or directory"
I am using AWS SAM.
I have created a samconfig.toml file with the following entry:
[default.build.parameters]
container_env_var_file = "envDefault.json"
When I do sam build I see in .aws-sam/build.toml
The env values from envDefault.json
But when I check the template .aws-sam/build/template.yaml
I see the original values, not the overwrites I have in envDefault.json
What is the best way to sam deploy with overwrites of the env variables for each environment I am deploying to?
I am trying to avoid entering parameters manually during the deploy process.
It seems you are trying to set build parameters not deploy parameters.
All the build parameters section in AWS SAM toml file starts with, [default.build.parameters]
And for the overriding deployment parameters, you have to use [default.deploy.parameters] section (default denotes the default profile).
So in your case, it will be like this.
[default.deploy.parameters]
parameter_overrides = "ParamKey=\"ParamValue\""
or you can use command line,
sam deploy --parameter-overrides
But if you are trying to get some values for your lambda functions based on environment, I strongly suggest the usage of parameter store.
I created and built a new CDK project:
mkdir myproj
cd myproj
cdk init --language typescript
npm run build
If I try to run the resulting javascript, I see the following:
PS C:\repos\myproj> node .\bin\myproj.js
CloudExecutable/1.0
Usage:
C:\repos\myproj\bin\myproj.js REQUEST
REQUEST is a JSON-encoded request object.
What is the right way to run my app?
You don't need to run your CDK programs directly, but rather use the CDK Toolkit instead.
To synthesize an AWS CloudFormation from your app:
cdk synth --app "node .\bin\myproj.js"
To avoid re-typing the --app switch every time, you can setup a cdk.json file with:
{ "app": "node .\app\myproj.js" }
Note: A default cdk.json is created by cdk init, so you should already see it under C:\repos\myproj.
You can also use the toolkit to deploy your app into an AWS environment:
cdk deploy
Or list all the stacks in your app:
cdk ls
The CDK application expects a request to be provided as a positional CLI argument when you're using the low-level API (aka running the app directly), for example:
node .\bin\myproj.js '{"type":"list"}'
It can also be passed as a Base64-encoded blob instead (that can make quoting the JSON less painful in a number of cases) - the Base64 needs to be prefixed with base64: in this case.
node .\bin\myproj.js base64:eyAidHlwZSI6ICJsaXN0IiB9Cg==
In order to determine what are the APIs that are available, and what arguments they expect, you can refer to the #aws-cdk/cx-api specification.
I'm trying to deploy my code to AWS Beanstalk and get this error. I researched that it could be that the number of versions is more than 500, so I deleted a lot of versions. But, I still get this error.
eb deploy
ERROR: No Application Version named 'v0_9_2-76-gf5a4' found.
I also tried
git aws.push
Error: Failed to create the AWS Elastic Beanstalk application version
Edit:
Trying with eb deploy --debug I now get:
Instance: i-2ad238d5 Module: AWSEBAutoScalingGroup ConfigSet: null Command failed on instance. Return code: 1 Output: Error occurred during build: Command hooks failed . Script /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed with returncode 18
ebcli.objects.exceptions.ServiceError: Update environment operation is
complete, but with errors. For more information, see troubleshooting
documentation.
Did you update the file .elasticbeanstalk/config.yml ? It may have a wrong setup.
Make a backup of .elasticbeanstalk/ folder and remove it
Execute eb create
Select the same region you deployed it before. You can check the region on .elasticbeanstalk/config.yml backup
A list with the environments will appear, select the right one
Deploy now
Remove the .elasticbeanstalk/config.yml backup
Check for the .elasticbeanstalk/config.yml file
environment: CORRECT_ENV_NAME
global:
application_name: CORRECT_APP_NAME
In my case, I was doing eb deploy X where X was an environment for a different project.
When I had the error
InvalidParameterValueError: No Application Version named 'app-9f5c-180927_071528' found.
I fixed this by specifying the label I wanted to push up.
eb deploy XXX-env -l XXX.0.0.1
The -l flag is documented AWS EB Deploy Docs
most likely, the deploy is trying an incorrect Elasticbeanstalk Application. it could be because you renamed the application in the AWS console.
so double check you're pointing to the correct elasticbeanstalk Environment and Application. it could be picking out default values from your .elasticbeanstalk/config.yml file.