'provider.deploymentBucket': unrecognized property 'accessLog' error in Serverless.yml - yaml

I have been trying to set the "Server access logging" for the deployment bucket in the serverless file with the following code:
deploymentBucket:
accessLog:
bucket: !Ref BucketReference
prefix: 'BucketPrefix'
The layout for the above code was found from using the "serverless-deployment-bucket", link here.
But following the steps that has been laid out in the documentation throws the following error when deploying to AWS:
Warning: Invalid configuration encountered
at 'provider.deploymentBucket': unrecognized property 'accessLog'
Not sure what I'm doing incorrectly

Related

Failed to build config.yaml when trying to implement mautrix-whatsapp

I'm trying to implement mautrix whatsapp into my Matrix server and I'm following this guide.
I copy example-config.yaml to config.yaml, change some settings and then I try to run ./mautrix-whatsapp -g; only to receive this error:
Error updating config: failed to unmarshal config: yaml: line 3: did not find expected key
Failed to parse config: yaml: line 3: did not find expected key
Can someone help?

Invalid Yaml: mapping values are not allowed here

Can anyone help me to figure out the following error while deploying react app on AWS elastic beanstalk -
2019-08-01 04:37:21 ERROR The configuration file .ebextensions/nodecommand.
config in application version app-5466-190801_100700 contains invalid YAML or JS
ON. YAML exception: Invalid Yaml: mapping values are not allowed here
in "<reader>", line 3, column 16:
option_settings:
^
, JSON exception: Invalid JSON: Unexpected character (/) at position 0.. Update
the configuration file.
2019-08-01 04:37:21 ERROR Failed to deploy application.
Following is my nodecommand.config file -
option_settings:
aws: elasticbeanstalk:container:nodejs:
NodeCommand: "node server.compiled.js"
Update -
I followed this link to deploy React app on AWS elastic beanstalk and stuck on above error -
https://medium.com/#wlto/how-to-deploy-an-express-application-with-react-front-end-on-aws-elastic-beanstalk-880ff7245008
This is what's shown in the linked tutorial:
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeCommand: "node server.compiled.js"
This is the YAML in your question:
option_settings:
aws: elasticbeanstalk:container:nodejs:
NodeCommand: "node server.compiled.js"
Can you spot the difference?
Spoiler: You've put a space after aws:. This causes the YAML parser to assume aws: is a mapping key with the value "elasticbeanstalk:container:nodejs:". However, the next line, which also starts with a mapping key (NodeCommand), is indented more, which would only be allowed if the previous line was a mapping key without a value.
If you remove the space, it correctly parses aws:elasticbeanstalk:container:nodejs as a mapping key and the following line as its value.
I was not actually had the problem fixed. I found this document[1] that says because my environment is using Amazon Linux 2, the ebextensions is not recommended. (But some of my ebextensions are still working. I have no idea about that). Instead, Buildfile, Procfile, and platform hooks are recommended. Therefore, I created a Procfile with the following content to make the Node server run with the command node index.js.
Procfile
web: node index.js
[1] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

How to write a policy in .yaml for a python lambda to read from S3 using the aws sam cli

I am trying to deploy a python lambda to aws. This lambda just reads files from s3 buckets when given a bucket name and file path. It works correctly on the local machine if I run the following command:
sam build && sam local invoke --event testfile.json GetFileFromBucketFunction
The data from the file is printed to the console. Next, if I run the following command the lambda is packaged and send to my-bucket.
sam build && sam package --s3-bucket my-bucket --template-file .aws-sam\build\template.yaml --output-template-file packaged.yaml
The next step is to deploy in prod so I try the following command:
sam deploy --template-file packaged.yaml --stack-name getfilefrombucket --capabilities CAPABILITY_IAM --region my-region
The lambda can now be seen in the lambda console, I can run it but no contents are returned, if I change the service role manually to one which allows s3 get/put then the lambda works. However this undermines the whole point of using the aws sam cli.
I think I need to add a policy to the template.yaml file. This link here seems to say that I should add a policy such as one shown here. So, I added:
Policies: S3CrudPolicy
Under 'Resources:GetFileFromBucketFunction:Properties:', I then rebuild the app and re-deploy and the deployment fails with the following errors in cloudformation:
1 validation error detected: Value 'S3CrudPolicy' at 'policyArn' failed to satisfy constraint: Member must have length greater than or equal to 20 (Service: AmazonIdentityManagement; Status Code: 400; Error Code: ValidationError; Request ID: unique number
and
The following resource(s) failed to create: [GetFileFromBucketFunctionRole]. . Rollback requested by user.
I delete the stack to start again. My thoughts were that 'S3CrudPolicy' is not an off the shelf policy that I can just use but something I would have to define myself in the template.yaml file?
I'm not sure how to do this and the docs don't seem to show any very simple use case examples (from what I can see), if anyone knows how to do this could you post a solution?
I tried the following:
S3CrudPolicy:
PolicyDocument:
-
Action: "s3:GetObject"
Effect: Allow
Resource: !Sub arn:aws:s3:::${cloudtrailBucket}
Principal: "*"
But it failed with the following error:
Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Invalid template property or properties [S3CrudPolicy]
If anyone can help write a simple policy to read/write from s3 than that would be amazing? I'll need to write another one so get lambdas to invoke others lambdas as well so a solution here (I imagine something similar?) would be great? - Or a decent, easy to use guide of how to write these policy statements?
Many thanks for your help!
Found it!! In case anyone else struggles with this you need to add the following few lines to Resources:YourFunction:Properties in the template.yaml file:
Policies:
- S3CrudPolicy:
BucketName: "*"
The "*" will allow your lambda to talk to any bucket, you could switch for something specific if required. If you leave out 'BucketName' then it doesn't work and returns an error in CloudFormation syaing that S3CrudPolicy is invalid.

How to set the "cluster" property in prisma.yml

Thanks for reading my question in advance. I am just start to use graphql and prisma following this tutorial.
I have the following Error when Deploying the Prisma database service:
Error: No cluster set. Please set the "cluster" property in your prisma.yml
at /Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/src/index.ts:89:11
at step (/Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/dist/index.js:40:23)
at Object.next (/Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/dist/index.js:21:53)
at fulfilled (/Users/judy/howtographql/server/node_modules/graphql-config-extension-prisma/dist/index.js:12:58)
at <anonymous>
error Command failed with exit code 1.
ERROR: "playground" exited with 1.
error Command failed with exit code 1.
I looked over the tutorial to find that there is nothing about how to set the cluster. I wonder how to fix this problem.
The default prisma.yaml is:
# the name for the service (will be part of the service's HTTP endpoint)
service: hackernews-graphql-js
# the cluster and stage the service is deployed to
stage: dev
# to disable authentication:
# disableAuth: true
secret: mysecret123
# the file path pointing to your data model
datamodel: datamodel.graphql
It could be just that you may have entered an incorrect endpoint address. Please refer https://github.com/prisma/graphql-config-extension-graphcool/issues/8

Load nested yaml properties using spring-boot

I have the following application-errors.yml file defined in src/main/resources of my Java spring-boot application:
client:
badrequest: {code: 001, message: 'Malformed request', status: 400}
configuration: {code: 002, message: 'Invalid EC2 VPC configuration', status: 400}
server:
unexpected.error:
code: 004
message: 'Unexpected error occurred. Please try again'
status: 500
Note that I've tried two different formats for specifying the properties.
I load that property file via the following Bean from a #Configuration annotated class:
#Bean
public static YamlPropertiesFactoryBean getYamlProperties() {
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("application-errors.yml"));
return yaml;
}
I see that the properties are loaded via the Spring Environment variable, but not in the pattern that I would expect. When debugging through, I can see that the source of the loaded property file contains the following values:
{client.badrequest=code:001 message:'Malformed request' status:400, client.configuration=code:002 message:'Invalid EC2 VPC configuration' status:400, server.unexpected.error=code:004 message:'Unexpected error occurred. Please try again' status:500}
It looks like the yaml file was flattened partially (only two levels deep). Instead, I was expecting each end property to be flattened on its own. The format that I was expecting would have been something like this:
{client.badrequest.code=001, client.badrequest.message='Malformed request', client.badrequest.status=400, client.configuration.code=002, client.configuration.message='Invalid EC2 VPC configuration', client.configuration.status=400, server.unexpected.error.code=004, server.unexpected.error.message='Unexpected error occurred. Please try again', server.unexpected.error.status=500}
What do I need to change in order to ensure Spring flattens the properties the entire way? If I'm not understanding either yaml formatting patterns or the pattern that Spring follows to flatten yaml files correctly, please correct my understanding.
I've found the multiple errors I made when arriving at this question this morning:
1) My code was not actually loading any custom named yml property files. Instead, it was picking up the default application.yml file that I also had in my project.
2) That default application.yml file had yml formatted code with the wrong syntax. Specifically, I had omitted the required space after each property identifier:
client:
badrequest:
code:001
message:'Malformed request'
status:400
configuration
code:002
message:'Invalid EC2 VPC configuration'
status:400
server:
unexpected.error
code:004
message:'Unexpected error occurred. Please try again'
status:500
After understanding those two issues, I was able to correctly load properties from application.yml.
The final syntax I landed on for my properties is the following:
# Error Properties
client:
badrequest: {code: 001, message: 'Malformed request', status: 400}
configuration: {code: 002, message: 'Invalid EC2 VPC configuration', status: 400}
server:
unexpected.error: {code: 004, message: 'Unexpected error occurred. Please try again', status: 500}

Resources