Skip to content

Instantly share code, notes, and snippets.

@adrianhall
adrianhall / .eslintrc.js
Last active April 29, 2024 15:01
A sample .eslintrc file
var OFF = 0, WARN = 1, ERROR = 2;
module.exports = exports = {
"env": {
"es6": true
},
"ecmaFeatures": {
// env=es6 doesn't include modules, which we are using
"modules": true
@adrianhall
adrianhall / AppSync-Example.yaml
Created April 13, 2018 16:01
An example CloudFormation template for AWS AppSync
---
Description: AWSAppSync DynamoDB Example
Resources:
GraphQLApi:
Type: "AWS::AppSync::GraphQLApi"
Properties:
Name: AWSAppSync DynamoDB Example
AuthenticationType: AWS_IAM
PostDynamoDBTableDataSource:
@adrianhall
adrianhall / AppSyncAPI.yaml
Last active March 19, 2023 14:57
A CloudFormation template for DynamoDB + Cognito User Pool + AppSync API for the Notes tutorial
---
Description: AWS AppSync Notes API
Parameters:
APIName:
Type: String
Description: Name of the API - used to generate unique names for resources
MinLength: 3
MaxLength: 20
AllowedPattern: '^[a-zA-Z][a-zA-Z0-9_]*$'
@adrianhall
adrianhall / graphql-policy.xml
Created June 1, 2022 16:20
An example Azure API Management policy for Synthetic GraphQL.
<policies>
<inbound>
<base />
<validate-graphql-request max-depth="3" />
</inbound>
<backend>
<set-graphql-resolver parent-type="Query" field="getAllTodoItems">
<http-data-source>
<http-request>
<set-method>GET</set-method>
@adrianhall
adrianhall / Program.cs
Created August 16, 2021 22:56
ASP.NET 6 CRUDL in 40 lines of code
using Microsoft.AspNetCore.Datasync;
using Microsoft.AspNetCore.Datasync.EFCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<AppDbContext>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddDatasyncControllers();
var app = builder.Build();
@adrianhall
adrianhall / openweathermap-api.yaml
Last active January 6, 2021 14:51
CLoudFormation Template for AWS AppSync OpenWeatherMap API
---
Description: GraphQL based OpenWeatherMap API
Parameters:
APIName:
Type: String
Description: Name of the API - used to generate unique names for resources
MinLength: 3
MaxLength: 20
AllowedPattern: '^[a-zA-Z][a-zA-Z0-9_]*$'
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: [DEBUG] AzureRM Request:
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: PUT /subscriptions/XXXXXXXX-0871-4889-9045-d554e72e0ef0/resourceGroups/smud-dev/providers/Microsoft.Web/sites/appwiflofbm?api-version=2019-08-01 HTTP/1.1
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: Host: management.azure.com
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: User-Agent: Go/go1.12.6 (amd64-windows) go-autorest/v13.3.0 Azure-SDK-For-Go/v38.1.0 web/2019-08-01 HashiCorp Terraform/0.12.24 (+https://www.terraform.io) Terraform Plugin SDK/1.6.0 terraform-provider-azurerm/2.2.0 pid-222c6c49-1b0a-5959-a213-6608f9eb88202020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: Content-Length: 1413
2020-03-25T11:21:10.221-0700 [DEBUG] plugin.terraform-provider-azurerm_v2.2.0_x5.exe: Content-Typ

What I'm trying to do

Write a python program (Python 3.8.2, Visual Studio Code insiders + insiders plugin, Windows 10) to upload a python file to a new storage blob, then set up distributed tracing and logging.

Starting application

This should be fairly basic.

  • pip install --pre azure.identity
#=======================================================================================
IdentityPool:
Type : AWS::Cognito::IdentityPool
Description : "Federation for the User Pool members to access AWS resources"
Properties:
IdentityPoolName : ${self:provider.apiname}_identities
AllowUnauthenticatedIdentities : true
CognitoIdentityProviders:
- ClientId : { Ref: AndroidUserPoolClient }
ProviderName : { Fn::Sub: [ 'cognito-idp.${self:provider.region}.amazonaws.com/#{client}', { "client": { Ref: CognitoUserPoolMyPool }}]}
#if($ctx.error)
$util.error($ctx.error.message, $ctx.error.type)
#end
#set($idList = [])
#foreach($item in $context.result.items)
$util.qr($idList.add($item.locationId))
#end
#set($result = {})
$util.qr($result.put("ids", $idList))