-
Create
static-build-frontend
script for deploying static web resources -
Run
static-build-frontend
script and Fix main frontend issues fix#1 and fix#2 -
Zip all static frontend content to deliver to S3
-
Create or install Gemfile for
aws_s3_website_sync
anddotenv
-
Create rake file for sync and run sync
-
Before run sync script don't forget run
npm install
andnpm build
in frontend dir
Rake file for sync
sync-static-s3
file:
#!/usr/bin/env ruby
puts("==== Installing <gem install aws_s3_website_sync> ====")
require 'bundler/inline'
require 'nokogiri'
gemfile do
source 'https://rubygems.org'
gem 'aws_s3_website_sync', require: true
gem 'dotenv', require: true
end
require 'aws_s3_website_sync'
require 'dotenv'
env_path = "/workspace/aws-bootcamp-cruddur-2023/erb/sync.env"
Dotenv.load(env_path)
puts "== configuration"
puts "aws_default_region: #{ENV["AWS_DEFAULT_REGION"]}"
puts "s3_bucket: #{ENV["SYNC_S3_BUCKET"]}"
puts "distribution_id: #{ENV["SYNC_CLOUDFRONT_DISTRUBTION_ID"]}"
puts "build_dir: #{ENV["SYNC_BUILD_DIR"]}"
changeset_path = ENV["SYNC_OUTPUT_CHANGESET_PATH"]
changeset_path = changeset_path.sub(".json","-#{Time.now.to_i}.json")
puts "output_changset_path: #{changeset_path}"
puts "auto_approve: #{ENV["SYNC_AUTO_APPROVE"]}"
puts("==== Syncing static content with AWS S3 Bucket ====")
puts "sync =="
AwsS3WebsiteSync::Runner.run(
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
aws_default_region: ENV["AWS_DEFAULT_REGION"],
s3_bucket: ENV["SYNC_S3_BUCKET"],
distribution_id: ENV["SYNC_CLOUDFRONT_DISTRUBTION_ID"],
build_dir: ENV["SYNC_BUILD_DIR"],
output_changset_path: changeset_path,
auto_approve: ENV["SYNC_AUTO_APPROVE"],
silent: "ignore,no_change",
ignore_files: [
'stylesheets/index',
'android-chrome-192x192.png',
'android-chrome-256x256.png',
'apple-touch-icon-precomposed.png',
'apple-touch-icon.png',
'site.webmanifest',
'error.html',
'favicon-16x16.png',
'favicon-32x32.png',
'favicon.ico',
'robots.txt',
'safari-pinned-tab.svg'
]
)
You should get All info about changes at your static content and invalidation
I, [2023-07-02T17:18:58.148418 #9677] INFO -- : Runner.run
I, [2023-07-02T17:18:58.148484 #9677] INFO -- : List.local
I, [2023-07-02T17:18:58.166242 #9677] INFO -- : List.remote
I, [2023-07-02T17:18:58.317970 #9677] INFO -- : Plan.delete
I, [2023-07-02T17:18:58.318070 #9677] INFO -- : Plan.create_update
---[ Plan ]------------------------------------------------------------
ChangeSet: changeset-1688318338
WebSync will perform the following operations:
update asset-manifest.json
update index.html
create static/js/main.a5e24caa.js
create static/js/main.a5e24caa.js.LICENSE.txt
create static/js/main.a5e24caa.js.map
delete static/js/main.b3a8eed0.js
delete static/js/main.b3a8eed0.js.LICENSE.txt
delete static/js/main.b3a8eed0.js.map
--------------------------------------------------------------------
ignore: 8 delete: 3 create: 3 update: 2 no_change: 23
...
Invalidation IF5LMAJ31WAWUV8YPWZDRP28R8 has been created. Please wait about 60 seconds for it to finish.
the main issues was in Lambda Post Confirmation function:
-
First Check code
-
Next check
CONNECTION_URL
and update it -
After run
schema-load
,migrate
andseed
scripts for Loading data into rds -
Delete your old user from
Cognito
and join one more time toomgchat.xyz
-
Check your connection to
prod
postresql, before that you'll need updateGITPOD_IP
,DB_SG_ID
andDB_SG_RULE_ID
and runupdate-sg-rule
to give access to RDS
You should have access
psql $CONNECTION_URL_PROD
- Check your new user from Database and run command bellow
You should see something like that, <cognito_user_id> shouldn't be empty
omgchat=> select * from users;
uuid | display_name | handle | email | cognito_user_id | created_at
--------------------------------------+-----------------+---------+--------------------------+--------------------------------------+----------------------------
7fd6217e-8515-4275-8d9e-957d700587dc | Aleksey Smirnov | smirnov | [email protected] | 9bf48207-9665-4f2d-8f1d-40da7007aa92 | 2023-07-03 16:15:04.243368
(4 rows)
omgchat=>
- Check that you can take a
Crud
, resolve issues
-
Add ENV VAR
DDB_MESSAGE_TABLE="OmgDdb-DynamoDBTable-KWLL3BZ0AUVY"
intobackend-flask.env
-
Change table name
ddb.py
4 line
table_name = os.getenv("DDB_MESSAGE_TABLE")
- Add ENV VAR to the
template.yaml
- Name: 'DDB_MESSAGE_TABLE'
Value: !Ref DDBMessageTable
- Create AWS CFN for MachineUser DynamoDB
AWSTemplateFormatVersion: '2010-09-09'
Resources:
OmgchatMachineUser:
Type: 'AWS::IAM::User'
Properties:
UserName: 'omgchat_machine_user'
DynamoDBFullAccessPolicy:
Type: 'AWS::IAM::Policy'
Properties:
PolicyName: 'DynamoDBFullAccessPolicy'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:GetItem
- dynamodb:Scan
- dynamodb:Query
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:BatchWriteItem
Resource: '*'
Users:
- !Ref OmgchatMachineUser
- Create and run script
#! /usr/bin/env bash
set -e
CYAN='\033[1;36m'
NO_COLOR='\033[0m'
LABEL="===== MachineUser for DDB CloudFormation deploy ====="
printf "${CYAN}==== ${LABEL}${NO_COLOR} ${CYAN}======${NO_COLOR}\n"
CFN_PATH="/workspace/aws-bootcamp-cruddur-2023/aws/cfn/machine-user/template.yaml"
REGION="eu-central-1"
STACK_NAME="OmgMachineUser"
BUCKET="omg-cfn-artifact"
aws cloudformation deploy \
--stack-name $STACK_NAME \
--s3-bucket $BUCKET \
--s3-prefix db \
--region $REGION \
--template-file $CFN_PATH \
--no-execute-changeset \
--tags group=omgchat-machine-user \
--capabilities CAPABILITY_NAMED_IAM
-
Refactoring routes -> commit
-
Add Initialization apps -> commit
-
Update activities and notification form > commit-1, commit-2, commit-3, commit-4
-
Configure migration, change
migration
and run db migrate script -
Fix DateTime -> commit
-
Refactory error handling and fetch request, update frontend -> commit
Well done, I'm done