Skip to content

Instantly share code, notes, and snippets.

View rfpedrosa's full-sized avatar
🏠
Working from home

Rui Pedrosa rfpedrosa

🏠
Working from home
View GitHub Profile
@rfpedrosa
rfpedrosa / db-migrations-spec.yml
Last active March 31, 2021 11:28
AWS CodePipeline: run migrations in AWS CodeBuild
# Based on https://github.com/PrakashTrove/AWS-CodeBuild-NetCore/blob/master/buildspec.yml
# AWS CodeBuild spec to run Entity Framework migrations before a deployment
# In order to AWS CodeBuild has access to RDS, I had to manually setup a Inbound rule:
# https://ctoasaservice.org/2019/01/23/aws-codebuild-and-access-to-rds/
version: 0.2
phases:
install:
runtime-versions:
dotnet: latest
@rfpedrosa
rfpedrosa / buildspec.yml
Last active July 7, 2020 18:18
AWS CodePipeline - buildspec.yml final file
# Based on https://github.com/PrakashTrove/AWS-CodeBuild-NetCore/blob/master/buildspec.yml
# AWS CodeBuild spec to build an Elastic Beanstalk artifact for AWS CodePipeline to deploy
version: 0.2
phases:
install:
runtime-versions:
dotnet: latest
pre_build:
@rfpedrosa
rfpedrosa / gist:34cac0f2168fa2476dd61d7dd6778b4a
Created June 16, 2020 16:44
Medium article: Asp.net core API project structure
dotnet new solution
dotnet new webapi -o Todo.Api
dotnet new classlib -o Todo.Core
dotnet sln add Todo.Api/Todo.Api.csproj Todo.Core/Todo.Core.csproj
dotnet add Todo.Api/Todo.Api.csproj reference Todo.Core/Todo.Core.csproj
@rfpedrosa
rfpedrosa / gist:5b79d2716aa4927a26a0d600a50a355d
Created November 29, 2019 15:52
log js errors using Amplify Hub and Analytics
import { Hub } from 'aws-amplify';
// Some HTTP request as an example that can be anywhere in your code
fetch(SOME_URL)
.then(function (response) {
if (!response.ok) {
console.log(`HTTP request succeed with unsuccessful response code of ${response.statusText}`);
Hub.dispatch(
'error',
{
@rfpedrosa
rfpedrosa / MyFunction-cloudformation-template.json
Last active November 27, 2019 15:56
MyFunction-cloudformation-template.json (FunctionErrorAlarm)
{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"Lambda resource stack creation using Amplify CLI",
"Parameters":{
...
},
"Conditions":{
...
},
"Resources":{
@rfpedrosa
rfpedrosa / MyFunction-cloudformation-template.json
Last active November 27, 2019 15:55
MyFunction-cloudformation-template.json (AWS::Metric::Filter only)
{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"Lambda resource stack creation using Amplify CLI",
"Parameters":{
...
"RetentionInDaysProd":{
"Type":"Number"
},
"RetentionInDaysOther":{
"Type":"Number"
@rfpedrosa
rfpedrosa / MyFunction-cloudformation-template.json
Last active November 27, 2019 14:14
MyFunction-cloudformation-template.json (just DurationAlarm)
{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"Lambda resource stack creation using Amplify CLI",
"Parameters":{
"env":{
"Type":"String"
},
"monitoringTopicsAlarmsTopicArn":{
"Type":"String"
},
@rfpedrosa
rfpedrosa / MyFunction-cloudformation-template.json
Last active November 27, 2019 13:58
MyFunction-cloudformation-template.json (just InvocationErrorAlarm)
{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"Lambda resource stack creation using Amplify CLI",
"Parameters":{
"env":{
"Type":"String"
},
"monitoringTopicsAlarmsTopicArn":{
"Type":"String"
}
@rfpedrosa
rfpedrosa / backend-config.json
Created November 26, 2019 21:21
backend-config.json (with MyFunction)
{
"monitoring":{
"Topics":{
"service":"SNS",
"providerPlugin":"awscloudformation"
}
},
"function":{
"MyFunction":{
"service":"Lambda",
@rfpedrosa
rfpedrosa / parameters.json
Last active November 26, 2019 21:03
Amplify monitory category - CF template parameters
{
"alarmsTopicName":"alarms",
"alarmsSubscriptionEmailProd":"[email protected]",
"alarmsSubscriptionEmailTest":"[email protected]"
}