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 / cdk.json
Last active January 26, 2021 18:10
Example cdk.json to test AWS CDK App Template deployment
{
"app": "npx ts-node bin/aws-cdk.ts",
"context": {
"app:name": "my-app",
"app:fullname": "My Awesome App",
"app:prodAwsAccountNumber": "",
"app:prodAwsRegion": "us-east-1",
"app:nonProdAwsAccountNumber": "[YOUR_NON_PROD_AWS_SUBACCOUNT_NUMBER]",
"app:nonProdAwsRegion": "us-east-1",
"@aws-cdk/core:enableStackNameDuplicates": "true",
@rfpedrosa
rfpedrosa / compute-stack.ts
Created January 26, 2021 12:56
compute-stack.ts (different platform or AMI)
// Running a different platform
const env = new elasticbeanstalk.CfnEnvironment(this, `${appName}-eb-${props.envName}`, {
environmentName: `${appName}-${props.envName}`,
applicationName: appName,
solutionStackName: '64bit Amazon Linux 2 v3.1.2 running Python 3.7',
optionSettings: options
})
// A specific AMI:
{
@rfpedrosa
rfpedrosa / integration-tests-buildspec.yml
Last active February 3, 2021 15:35
AWS CodeBuild spec file to run integration tests
# AWS CodeBuild buildspec file to run in a [mcr.microsoft.com/dotnet/sdk:5.0.101-focal](https://hub.docker.com/_/microsoft-dotnet-sdk) image
# "POST_BUILD will always run as long as BUILD was also run (regardless of BUILD's success or failure.)
# The same goes for UPLOAD_ARTIFACTS. This is so you can retrieve debug information/artifacts."
# So that is why we have tests as an independent step instead of having in buildspec.yml file
version: 0.2
#env:
#variables:
#ASPNETCORE_ENVIRONMENT: Test
#ConnectionStrings__IntegrationTestsDb: Host=localhost;Port=5432;Database=integration_tests_{0};Username=integration_tests;Password=reallyStrongPwd123;Maximum Pool Size=1
@rfpedrosa
rfpedrosa / SetQuantities.cs
Created December 22, 2020 10:13
integration_tests - SetQuantities.cs using BaseEfRepoTestFixture
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.ApplicationCore.Services;
using Microsoft.eShopWeb.UnitTests.Builders;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
namespace Microsoft.eShopWeb.IntegrationTests.Repositories.BasketRepositoryTests
{
@rfpedrosa
rfpedrosa / BaseEfRepoTestFixture.cs
Last active December 22, 2020 10:57
integration_tests - create and delete db (BaseEfRepoTestFixture.cs)
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.Infrastructure.Data;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.eShopWeb.IntegrationTests.Repositories
{
// Based on https://github.com/ardalis/CleanArchitecture/blob/master/tests/CleanArchitecture.IntegrationTests/Data/BaseEfRepoTestFixture.cs
@rfpedrosa
rfpedrosa / IntegrationTests.csproj
Created December 21, 2020 20:44
integration_tests_first commit (IntegrationTests.csproj)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.IntegrationTests</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="5.0.0" />
@rfpedrosa
rfpedrosa / SetQuantities.cs
Last active December 22, 2020 11:00
integration_tests_first commit (SetQuantities.cs)
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.ApplicationCore.Services;
using Microsoft.eShopWeb.Infrastructure.Data;
using Microsoft.eShopWeb.UnitTests.Builders;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
@rfpedrosa
rfpedrosa / rds_native_backup.sql
Created July 9, 2020 23:29
RDS Native backup for SQL Server
-- create native DB backup
exec msdb.dbo.rds_backup_database
@source_db_name='MY_DB_NAME',
@s3_arn_to_backup_to='arn:aws:s3:::my-db-name-rds-backups/0.9.9.bak',
@overwrite_s3_backup_file=1,
@type='FULL';
-- see status of backup
exec msdb.dbo.rds_task_status @task_id=7;
@rfpedrosa
rfpedrosa / Api.csproj
Created July 8, 2020 09:24
Asp.net core .ebextensions in csproj
<ItemGroup>
<!-- AWS Elastic Beanstalk stuff https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-dotnet-core-linux.html -->
<None Include=".ebextensions\alb-default-process.config" CopyToOutputDirectory="Always" />
<None Include=".ebextensions\env.config" CopyToOutputDirectory="Always" />
<None Include=".ebextensions\logging.config" CopyToOutputDirectory="Always" />
</ItemGroup>
@rfpedrosa
rfpedrosa / env.config
Created July 8, 2020 09:21
Asp.net Core .ebextensions for env/port
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: PORT
value: 5000