added cognito initial config
This commit is contained in:
41
build.sh
41
build.sh
@@ -1,32 +1,63 @@
|
||||
#!/bin/sh
|
||||
|
||||
# create folder to pack all
|
||||
echo "Starting build process..."
|
||||
mkdir build
|
||||
cd main-web/client
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/client/client build
|
||||
|
||||
# build janken tool and move
|
||||
cd tools/janken
|
||||
echo "Starting janken tool build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
mv tools/janken/tool build
|
||||
echo "Finished janken tool build..."
|
||||
|
||||
# build client and move
|
||||
cd main-web/client
|
||||
echo "Starting client build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/client/client build
|
||||
echo "Finished client build..."
|
||||
|
||||
# build admin and move
|
||||
cd main-web/admin
|
||||
echo "Starting admin ui build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
mv main-web/admin/build build/admin
|
||||
echo "Finished admin ui build..."
|
||||
|
||||
# build server and move
|
||||
cd main-web/server
|
||||
echo "Starting server build..."
|
||||
npm run build
|
||||
cd ../../
|
||||
cd build/
|
||||
echo "Starting retrieval of db credentials..."
|
||||
export catherine_db_endpoint=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-endpoint" --with-decryption --output text --query Parameter.Value)
|
||||
export catherine_db_user=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-username" --with-decryption --output text --query Parameter.Value)
|
||||
export catherine_db_pass=$(aws --region=ap-northeast-1 ssm get-parameter --name "db-password" --with-decryption --output text --query Parameter.Value)
|
||||
echo "Saving db credentials to .env file..."
|
||||
cat > .env <<EOL
|
||||
DB_ENDPOINT=${catherine_db_endpoint}
|
||||
DB_USER=${catherine_db_user}
|
||||
DB_PASS=${catherine_db_pass}
|
||||
EOL
|
||||
cd ../
|
||||
cp main-web/server/.env build/
|
||||
cp main-web/server/package.json build/
|
||||
cp main-web/server/tsconfig.json build/
|
||||
cp main-web/server/tslint.json build/
|
||||
mv main-web/server/build build/server
|
||||
echo "Finished server build..."
|
||||
|
||||
echo "Compressing all files..."
|
||||
tar czf build.tar.gz build/
|
||||
echo "Finished compressing all files..."
|
||||
echo "Removing workfolder..."
|
||||
rm -rf build/
|
||||
echo "Removed workfolder..."
|
||||
|
||||
echo "Upload built files to s3..."
|
||||
aws s3 cp build.tar.gz s3://catherine-fc-infra/
|
||||
echo "Finished build process..."
|
||||
|
||||
23
infra/terraform/modules/catherine-fc/main/cognito.tf
Normal file
23
infra/terraform/modules/catherine-fc/main/cognito.tf
Normal file
@@ -0,0 +1,23 @@
|
||||
resource "aws_cognito_user_pool" "catherine_fc_admin_cognito_pool" {
|
||||
name = "catherine-fc-admin"
|
||||
|
||||
admin_create_user_config {
|
||||
allow_admin_create_user_only = true
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_cognito_user_pool_client" "catherine_fc_admin_cognito_pool_client" {
|
||||
name = "catherine-fc-admin-client"
|
||||
user_pool_id = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.id
|
||||
allowed_oauth_flows = ["code","implicit"]
|
||||
allowed_oauth_scopes = ["email", "openid"]
|
||||
callback_urls = ["https://www.catherine-fc.com","https://catherine-fc.com"]
|
||||
allowed_oauth_flows_user_pool_client = true
|
||||
generate_secret = true
|
||||
explicit_auth_flows = ["USER_PASSWORD_AUTH"]
|
||||
}
|
||||
|
||||
resource "aws_cognito_user_pool_domain" "catherine_fc_admin_cognito_pool_domain" {
|
||||
domain = "catherine-fc-admin-domain"
|
||||
user_pool_id = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.id
|
||||
}
|
||||
@@ -21,3 +21,57 @@ resource "aws_lb_listener" "catherine_fc_load_balancer_listener" {
|
||||
target_group_arn = aws_lb_target_group.target_group_web.arn
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_lb_listener_rule" "catherine_fc_alb_listener_admin" {
|
||||
listener_arn = aws_lb_listener.catherine_fc_load_balancer_listener.arn
|
||||
priority = 1
|
||||
action {
|
||||
type = "authenticate-cognito"
|
||||
|
||||
authenticate_cognito {
|
||||
user_pool_arn = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.arn
|
||||
user_pool_client_id = aws_cognito_user_pool_client.catherine_fc_admin_cognito_pool_client.id
|
||||
user_pool_domain = aws_cognito_user_pool_domain.catherine_fc_admin_cognito_pool_domain.domain
|
||||
on_unauthenticated_request = "authenticate"
|
||||
session_cookie_name = "CatherineFCAdmin"
|
||||
session_timeout = 86400
|
||||
}
|
||||
}
|
||||
action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.target_group_web.arn
|
||||
}
|
||||
|
||||
condition {
|
||||
path_pattern {
|
||||
values = ["/admin*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "aws_lb_listener_rule" "catherine_fc_alb_listener_admin_api" {
|
||||
listener_arn = aws_lb_listener.catherine_fc_load_balancer_listener.arn
|
||||
priority = 2
|
||||
action {
|
||||
type = "authenticate-cognito"
|
||||
|
||||
authenticate_cognito {
|
||||
user_pool_arn = aws_cognito_user_pool.catherine_fc_admin_cognito_pool.arn
|
||||
user_pool_client_id = aws_cognito_user_pool_client.catherine_fc_admin_cognito_pool_client.id
|
||||
user_pool_domain = aws_cognito_user_pool_domain.catherine_fc_admin_cognito_pool_domain.domain
|
||||
on_unauthenticated_request = "deny"
|
||||
session_cookie_name = "CatherineFCAdmin"
|
||||
session_timeout = 86400
|
||||
}
|
||||
}
|
||||
action {
|
||||
type = "forward"
|
||||
target_group_arn = aws_lb_target_group.target_group_web.arn
|
||||
}
|
||||
|
||||
condition {
|
||||
path_pattern {
|
||||
values = ["/api/admin*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
import React, { FunctionComponent } from 'react';
|
||||
import style from '../web.module.scss';
|
||||
import YouTube from 'react-youtube';
|
||||
|
||||
type ComponentProps = {
|
||||
};
|
||||
|
||||
export const Home: FunctionComponent<ComponentProps> = (props): JSX.Element => {
|
||||
|
||||
const opts = {
|
||||
height: '696',
|
||||
width: '1024'
|
||||
};
|
||||
return (
|
||||
<div className={style.mainBody}>
|
||||
<div className={style.chalice} />
|
||||
@@ -16,11 +21,10 @@ export const Home: FunctionComponent<ComponentProps> = (props): JSX.Element => {
|
||||
<div className={style.twitchHome}>
|
||||
<a href='https://www.twitch.tv/catherine_faito_crab' rel='noopener noreferrer' target='_blank'> </a>
|
||||
</div>
|
||||
<div className={style.players0801} />
|
||||
<div className={style.players0802} />
|
||||
<div className={style.players0808} />
|
||||
<div className={style.players0809} />
|
||||
<div className={style.players0815} />
|
||||
<YouTube
|
||||
videoId={'oetCaugzOew'}
|
||||
opts={opts}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -141,6 +141,7 @@ app.get('/api/contact', (req: any, res: any) => {
|
||||
);
|
||||
});
|
||||
|
||||
app.use('/admin', express.static('admin'));
|
||||
app.use('/players', express.static('client'));
|
||||
app.use('/tournaments*', express.static('client'));
|
||||
app.use('/about', express.static('client'));
|
||||
|
||||
Reference in New Issue
Block a user