Skip to content

Instantly share code, notes, and snippets.

@jhw
Last active July 1, 2024 14:15
Show Gist options
  • Save jhw/339859004221f36b6e034fe74d4b0576 to your computer and use it in GitHub Desktop.
Save jhw/339859004221f36b6e034fe74d4b0576 to your computer and use it in GitHub Desktop.
Cognito Google federated auth deploy test
env
*.pyc
__pycache__
tmp
setenv-priv.sh
AppName=polyreader-social-demo
#!/usr/bin/env bash
. app.props
aws cloudformation delete-stack --stack-name $AppName
#!/usr/bin/env bash
. app.props
aws cloudformation deploy --stack-name $AppName --template-file stack.json --capabilities CAPABILITY_NAMED_IAM --parameter-overrides DomainName=$DOMAIN_NAME GoogleClientId=$GOOGLE_CLIENT_ID GoogleClientSecret=$GOOGLE_CLIENT_SECRET
#!/usr/bin/env bash
. app.props
aws cloudformation describe-stack-events --stack-name $AppName --query "StackEvents[].{\"1.Timestamp\":Timestamp,\"2.Id\":LogicalResourceId,\"3.Type\":ResourceType,\"4.Status\":ResourceStatus,\"5.Reason\":ResourceStatusReason}"
#!/usr/bin/env bash
. app.props
aws cloudformation describe-stacks --stack-name $AppName --query 'Stacks[0].Outputs' --output table
#!/usr/bin/env bash
. app.props
aws cloudformation describe-stack-resources --stack-name $AppName --query "StackResources[].{\"1.Timestamp\":Timestamp,\"2.LogicalId\":LogicalResourceId,\"3.PhysicalId\":PhysicalResourceId,\"4.Type\":ResourceType,\"5.Status\":ResourceStatus}"
#!/usr/bin/env bash
aws cloudformation describe-stacks --query "Stacks[].{\"1.Name\":StackName,\"2.Status\":StackStatus}"
awscli
botocoro
boto3
pyyaml
#!/usr/bin/env bash
export AWS_DEFAULT_OUTPUT=table
export AWS_PROFILE=#{your-aws-profile-here}
export AWS_REGION=#{your-aws-region-here}
export DOMAIN_NAME=#{your-domain-name-here}
export GOOGLE_CLIENT_ID=#{your-google-client-id-here}
export GOOGLE_CLIENT_SECRET=#{your-google-client-secret-here}
{
"Outputs": {
"AppUserPool": {
"Value": {
"Ref": "AppUserPool"
}
},
"AppUserPoolClient": {
"Value": {
"Ref": "AppUserPoolClient"
}
},
"AppUserPoolDomain": {
"Value": {
"Ref": "AppUserPoolDomain"
}
}
},
"Parameters": {
"DomainName": {
"Type": "String"
},
"GoogleClientId": {
"Type": "String"
},
"GoogleClientSecret": {
"Type": "String"
}
},
"Resources": {
"AppUserPool": {
"Properties": {
"AutoVerifiedAttributes": [
"email"
],
"Policies": {
"PasswordPolicy": {
"MinimumLength": 8,
"RequireLowercase": true,
"RequireNumbers": true,
"RequireSymbols": true,
"RequireUppercase": true
}
},
"Schema": [
{
"AttributeDataType": "String",
"Mutable": true,
"Name": "email",
"Required": true,
"StringAttributeConstraints": {
"MinLength": "1"
}
},
{
"AttributeDataType": "String",
"Mutable": true,
"Name": "foo"
}
],
"UsernameAttributes": [
"email"
],
"UsernameConfiguration": {
"CaseSensitive": false
}
},
"Type": "AWS::Cognito::UserPool"
},
"AppUserPoolClient": {
"Properties": {
"CallbackURLs": [
{
"Fn::Sub": "https://${AppUserPoolDomain}.auth.${AWS::Region}.amazoncognito.com/oauth2/idpresponse"
}
],
"ExplicitAuthFlows": [
"ALLOW_USER_SRP_AUTH",
"ALLOW_ADMIN_USER_PASSWORD_AUTH",
"ALLOW_REFRESH_TOKEN_AUTH"
],
"LogoutURLs": [
{
"Fn::Sub": "https://${DomainName}"
}
],
"PreventUserExistenceErrors": "ENABLED",
"SupportedIdentityProviders": [
"COGNITO",
"Google"
],
"UserPoolId": {
"Ref": "AppUserPool"
}
},
"Type": "AWS::Cognito::UserPoolClient"
},
"AppUserPoolDomain": {
"Properties": {
"Domain": {
"Fn::Sub": "${AWS::StackName}"
},
"UserPoolId": {
"Ref": "AppUserPool"
}
},
"Type": "AWS::Cognito::UserPoolDomain"
},
"GoogleUserPoolIdentityProvider": {
"Properties": {
"ProviderDetails": {
"authorize_scopes": "openid email profile",
"client_id": {
"Ref": "GoogleClientId"
},
"client_secret": {
"Ref": "GoogleClientSecret"
}
},
"ProviderName": "Google",
"ProviderType": "Google",
"UserPoolId": {
"Ref": "AppUserPool"
}
},
"Type": "AWS::Cognito::UserPoolIdentityProvider"
}
}
}

short

  • test deployment

pareto2

  • UserPoolIdentityProvider needs to subclass name so has a Google- prefix

done

  • env variables
  • modify deploy.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment