Serverless - Schedule event not creating CloudWatch Events - serverless

Serverless isn't creating CloudWatch Events as a trigger to a lambda. There are no warnings or errors.
functions:
aggregate:
handler: statistics.handler
events:
- schedule:
rate: rate(10 minutes)

Serverless' examples don't demonstrate the critical nature of the indentation. https://serverless.com/framework/docs/providers/aws/events/schedule/#schedule
functions:
aggregate:
handler: statistics.handler
events:
# "- schedule:" has to start at the same indentation as the "events:" above it.
- schedule:
# The CloudWatch Events Rules have to be exactly 4 spaces indented below the "- schedule:"
rate: rate(10 minutes)
# ... other fields
Crtical:
Align - schedule: with events: above it.
Align the next row e.g. rate: rate(6 minutes) 4 spaces indented from the - schedule:
Example code:
service: my-service
provider:
name: aws
region: us-west-2
runtime: nodejs10.x
functions:
hello:
handler: handler.hello
events:
- schedule:
rate: cron(*/5 * * * ? *)
enabled: true
with
module.exports.hello = (event, context, callback) => {
console.log("Hello, world!");
callback(null);
};
Simply indenting - schedule 2 spaces like I'd expect does not create cloudwatch events in AWS. That single change of 2 spaces makes the difference between whether the cloudwatch event rule is created or not.
Note: No errors are thrown between the two indents, but it creates 6 vs. 8 AWS resources (2 missing don't create cloudwatch event rules).

Related

Cypress 12 + angular 15 + input chain failling randomly

I just migrate my application from angular 12 to angular 15 (and material 15).
The cypress also migrated from 8.7.0 to 12.3.0
Since the migration, the existing cypress tests are not constant in execution.
I have too kinds of issue:
Cannot get element by id or css class. The error is “…is being covered by another element“
Synchronisation is not perfect on input chaining. As example :
cy.get('#birthPlace_id') .clear() .type('London') .should('have.class', 'ng-valid');
In this test code execution, the type starts meanwhile the clear instruction is not completely finished. This give a wrong input value with a mix of previous and new typed values.
Here is my configuration:
`
defaultCommandTimeout: 60000,
execTimeout: 60000,
pageLoadTimeout: 60000,
requestTimeout: 60000,
responseTimeout: 60000,
taskTimeout: 60000,
videoUploadOnPasses: true,
screenshotOnRunFailure: false,
videoCompression: false,
numTestsKeptInMemory: 0,
animationDistanceThreshold: 20,
waitForAnimations: false,
env: { 'NO_COLOR': '1' },
retries: {
runMode: 4,
openMode: 0
},
fileServerFolder: '.,',
modifyObstructiveCode: false,
video: false,
chromeWebSecurity: true,
component: {
devServer: {
framework: 'angular',
bundler: 'webpack'
}
}
`
I already tried to:
Add “force: true”
Add a wait(1000) or another value
Use click() method before
I increased the timeout in the config file for all
But same comportment randomly it can also work perfectly, but major time not at all.
I would expect that the call to clear(), type(), should() are perfectly synchronised and does not start before the previous one is not finished yet.
My question: is there a better way to do chaining ? Does something change since Cypress 8 to chain instruction on element ?
In this test code execution, the type starts meanwhile the clear instruction is not completely finished.
You can guard against this by adding an assertion after .clear().
This retries the test flow until the control has been cleared.
cy.get('#birthPlace_id')
.clear()
.should('have.value', '')
.type('London')
.should('have.value', 'London')

Google Calendar Link Generator - Repeat event

I'm finding a webtool to generate a Google Calendar link event with a repeat parameters. For example I would like to create an event with this data:
Title: Example event
Location: Office
Description: This is a description of an example event.
Start Date: 01/10/2021
Start Time: 10:00:00h
Repeat at: each months.
I have found URL as like:
https://jennamolby.com/google-calendar-link-generator/
But in this URL I cann't to set a repeat parameter.
An URL example without repeat time event parameter is this:
http://www.google.com/calendar/event?action=TEMPLATE&dates=20211001T100000Z%2FT010000Z&text=Example%20event&location=Office&details=This%20is%20a%20description%20of%20an%20example%20event.%20
I would like to find documentation about all possible parameters to create Google Calendar events.
Thanks.
The parameter to insert a repeat event is:
&recur=RRULE:FREQ%3DMONTHLY&sf=true
In this example the repeat is monthly.

How to make TypeORM save values of CreateDateColumn, UpdateDateColumn in UTC?

The columns use current timestamp. How do I make it UTC?
#CreateDateColumn({
type: 'timestamptz',
name: 'create_date'
})
private createDate: Moment;
#UpdateDateColumn({
type: 'timestamptz',
name: 'update_date',
})
private updateDate: Moment;
You have some options.
1 - Create the columns directly from postgres query:
create temporary table test(
id int,
create_date timestamp without time zone default (now() at time zone 'utc')
);
2 - Convert to UTC in application and create the column with { type: 'timestamptz' }
You can take a look at this link and check if one of the solutions solves your problem.

Simplest and Optimised way to read and edit YAMLs

I've some YAML files which I wanted to apply to create Custom Resources. But before applying it I want to change the spec and ENVs of the YAML snippet. So what could be the best way to do this?
What I'm doing now is:
Let suppose this is the YAML
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: nginx-chaos
namespace: default
spec:
appinfo:
appns: 'default'
applabel: 'app=nginx'
appkind: 'deployment'
# It can be true/false
annotationCheck: 'false'
# It can be active/stop
engineState: 'active'
chaosServiceAccount: pod-delete-sa
monitoring: false
# It can be delete/retain
jobCleanUpPolicy: 'delete'
experiments:
- name: pod-delete
spec:
components:
env:
# set chaos duration (in sec) as desired
- name: TOTAL_CHAOS_DURATION
value: '30'
# set chaos interval (in sec) as desired
- name: CHAOS_INTERVAL
value: '10'
# pod failures without '--force' & default terminationGracePeriodSeconds
- name: FORCE
value: 'false'
I Download this file from the raw link. (1 function for this)
Replace a field like jobCleanUpPolicy: 'delete' to jobCleanUpPolicy: 'retain' (1 fn)
Replace the next line when a match is found like value: 'false' to value: 'true' for FORCE ENV. (1 fn)
Applying the final manifest created! (1 function)
Can this be optimized?
If you create a struct representing the resource (or, even better, can import the package which defines the CRD) you could take the yaml string, marshal it into the struct and then edit the fields directly as fields of a struct instead
Hi You may use LitmusPortal to use this.Refer

Resque scheduler pass hash argument to Job

I have a job that receives a hash argument in its perform method. I want to call it periodically. I defined a CRON to schedule it on the resque_schedule.yml file. I am trying this way:
UpdateInterestHistoryJob:
cron: "0 0 * * * America/Sao_Paulo"
args:
classifier: :SIAPE
However, inside the job, I get the arguments as an array:
["classifier", "SIAPE"]
How do I define it correctly? How do I define the job argument as a hash on the yml file?
I just tested here and a simple dash should be enough:
UpdateInterestHistoryJob:
cron: "* * * * * America/Sao_Paulo"
args:
- classifier: :SIAPE
Also, should you need more arguments in your Resque job, simply place them without further dashes:
UpdateInterestHistoryJob:
cron: "* * * * * America/Sao_Paulo"
args:
- classifier: :SIAPE
another: value
between your Hash and the one included in this example from Ceilingfish I see discrepancy:
You can mark it up like this
feeds:
-
url: 'http://www.google.com'
label: 'default'
Note the spacing is important here. "-" must be indented by a single space (not a tab), and followed by a single space. And url & label must be indented by two spaces (not tabs either).
Additionally this might be helpful: http://www.yaml.org/YAML_for_ruby.html
This is from ww.yaml.org
Simple Inline Hash
Mapping can also be contained on a single line, using the inline syntax. Each key-value pair is separated by a colon, with a comma between each entry in the mapping. Enclose with curly braces.
Yaml
Simple Inline Hash in YAML?
hash: { name: Steve, foo: bar }
Ruby
Simple Inline Hash in Ruby?
{ 'hash' => { 'name' => 'Steve', 'foo' => 'bar' } }
I also include this link from the official YAMLSyntax and there is many explanation about this
Convert Ruby Hash into YAML
https://codedump.io/share/w2EriSJ0wO7T/1/convert-ruby-hash-into-yaml

Resources