DEV Community

Cover image for Angular Build Upload to AWS S3 + Cloudfront

Angular Build Upload to AWS S3 + Cloudfront

Avinash Dalvi
AWS Community Builder | Full Stack Developer | PHP + Angular + Python + AWS | Speaker | Blogger | Leadership I write blog at
・1 min read

Published Python automated script for Angular project deployment to AWS S3 and Cloudfront.

This will help to automated uploading Angular project build code to AWS S3 and CloudFront cached invalidation part. This will ensure to take backup of existing code for rollback operation if required.

from deployment_angular_s3_cloudfront import *

from constants import REQUEST_PARAMS

import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--env', help="Select Environment PROD/STAGE/DEV")
parser.add_argument('--codepath', help="Code path of UI code")
parser.add_argument('--buildpath', help="Build path of UI code")
args = parser.parse_args()
if args.env:
    env = args.env
    env = "STAGE"
if args.codepath:
    code_path = args.codepath
    code_path = REQUEST_PARAMS.get(env).get('repositoryPath')

if args.buildpath:
    build_path = args.buildpath
    build_path = REQUEST_PARAMS.get(env).get('buildPath')

print("Starting process for %s environment" %env)
request = {
    'bucketName': REQUEST_PARAMS.get(env).get('bucketName'), 
    'buildPath': build_path,
    'repositoryPath': code_path,
    'envName':  env,  # 'DEV, STAGE,PROD'
    'distributionId': REQUEST_PARAMS.get(env).get('distributionId'),
    'portal': 'PROJECTNAME',
    'buildCommand': REQUEST_PARAMS.get(env).get('buildCommand')
obj = DeploymentService(request)
Enter fullscreen mode Exit fullscreen mode

Contribution for this repository is open. pip package process in progress.

Discussion (0)