A quick post on how to merge a multiline block into a single line using Visual Studio Code:
-- From this
CREATE TABLE posts
post_id INT IDENTITY(1,1) PRIMARY KEY,
user_id VARCHAR(255) NOT NULL,
created DATETIME NOT NULL,
updated DATETIME NOT NULL,
version INT NOT NULL,
up_votes INT NOT NULL,
down_votes INT NOT NULL,
updated DATETIME NOT NULL
-- To this
CREATE TABLE posts ( post_id INT IDENTITY(1,1) PRIMARY KEY, title VARCHAR(100), description VARCHAR(MAX), user_id VARCHAR(255) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, version INT NOT NULL, up_votes INT NOT NULL, down_votes INT NOT NULL, updated DATETIME NOT NULL )
Simply highlight your code block, press F1, and then type “join lines”. Pressing enter will join everything. If you’re on a mac you can also use ctrl+j.
Today I’ve added local overrides to the global variables in my template.yml file. This was pretty finicky – a lot of conflicting suggestions out there unfortunately. These are the settings that ended up working for me.
I’ve spent today implementing Cognito with AWS SAM and it took quite a while to work out what needed to be done – unfortunately there’s a lot of conflicting doco out there. Posting a sample template just in case it’s able to help anyone else out.
The first thing to do is to explicitly define you rest API. By default AWS SAM will generate one with a default logical id of ServerlessRestApi. You’ll need to override this:
# See links for more info
# Referencing cognito authorizer: https://github.com/awslabs/serverless-application-model/issues/512#issuecomment-411284092
# Logical id is auto generated: https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
# Sample template.yml: https://github.com/awslabs/serverless-application-model/blob/release/v1.8.0/examples/2016-10-31/api_cognito_auth/template.yaml
Auth: # We will eventually define other auth options here such as Usage Plans/Api Keys, AWS_IAM, and Resource Policies
UserPoolArn: !GetAtt MyCustomCognitoUserPool.Arn # Can be a string, or array
# Identity: # Optional
# Header: ... # Optional; Default: Authorization
# ValidationExpression: ... # Optional; ensures the request header matches a pattern before checking in with the Authorizer endpoint; is there a default we can set for Cognito User Pools Auth?
You’ll also need to create a user pool and client:
You then add the api id and the auth attribute to each of your function properties. If you’ve used the default authorizer property when defining the associated api you can override it by using authorizer: none.
Then save the file. Your raspberry pi will now connect to the network with the highest priority first (home network), when that’s not available it will use the network with the lower priority (mobile network).