Skip to content

Instantly share code, notes, and snippets.

View fredericbarthelet's full-sized avatar

Frédéric Barthelet fredericbarthelet

View GitHub Profile
@fredericbarthelet
fredericbarthelet / serverless.ts
Created April 28, 2022 15:50
Serverless to CDK bridge with HttpApi extension
import type { AWS } from '@serverless/typescript';
import { App, Stack, Fn } from 'aws-cdk-lib';
// import { CfnApiMapping } from 'aws-cdk-lib/aws-apigatewayv2'
import { Certificate } from 'aws-cdk-lib/aws-certificatemanager'
import { ApiMapping, DomainName, HttpApi, HttpStage } from '@aws-cdk/aws-apigatewayv2-alpha';
const app = new App();
class MyStack extends Stack {
constructor(scope, id) {
super(scope, id);
@fredericbarthelet
fredericbarthelet / create.ts
Last active June 30, 2021 19:27
Lamba create.ts with intrinsic service
import { DynamoDB } from 'aws-sdk';
import { ref } from './intrinsic';
import cloudformationResources, { MyTable } from './resources';
export default {
handler:'create.main',
environment: {
TABLE_NAME: ref(cloudformationResources, MyTable)
},
@fredericbarthelet
fredericbarthelet / intrinsic.ts
Created October 11, 2020 15:17
AWS intrinsic function resolution
import {
CloudFormationResource,
CloudFormationResources,
} from 'serverless/aws';
import { findKey } from 'lodash';
interface CloudFormationReference {
Ref: string;
}
@fredericbarthelet
fredericbarthelet / create.ts
Last active June 30, 2021 19:27
lambda with dynamo
import { DynamoDB } from 'aws-sdk';
export default {
handler:'create.main',
environment: {
TABLE_NAME: {
Ref: 'MyTable'
}
},
events: [
@fredericbarthelet
fredericbarthelet / functions.ts
Last active June 30, 2021 19:27
Serverless.ts complex project imports
export { default as hello } from './hello';
export { default as goodbye } from './goodbye';
@fredericbarthelet
fredericbarthelet / functions.ts
Created October 11, 2020 11:07
Serverless.ts splitting
export default {
hello: {
handler: 'index.hello'
},
goodbye: {
handler: 'index.goodbye'
}
};
@fredericbarthelet
fredericbarthelet / functions.yml
Created October 11, 2020 10:57
Serverless.yml splitting
hello:
handler: index.hello
goodbye:
handler: index.goodbye
@fredericbarthelet
fredericbarthelet / serverless.yml
Last active October 11, 2020 10:54
Serverless all-in-one definition
service: myServerlessService
provider:
name: aws
runtime: nodejs12.x
functions:
hello:
handler: index.hello
goodbye:
@fredericbarthelet
fredericbarthelet / s3-bucket.yml
Created April 26, 2020 19:19
CloudFormation template
AWSTemplateFormatVersion: 2010-09-09
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
DeletionPolicy: Retain
namespace App\EventListener;
use App\Entity\Counting;
use App\Entity\User;
use Doctrine\ORM\Event\PrePersistEventArgs;
use Symfony\Component\Security\Core\Security;
class CountingEventListener
{
/**