Integration of Glue [Serverless Data Integration Service] with CI/CD
Tags: awsglue, cloudformation, s3, codepipeline
Published: 2022-08-07 18:16:08

“ I have checked the solution to deploy the script code change sequentially with approval in different accounts such as dev, qa and prod. Also the change in configuration of glue should be proper. I have faced an issue while using one common bucket for dev, qa and prod environment for giving python script code, this code is parallelly updated on each environment. But the requirement is to update the code in dev first then after approval update the code to qa then after approval update of code in prod. The solution is only possible when I deploy the glue script python code using codepipeline and glue config using cloudformation stack. The solution works well as per the requirement. Solution is secured with kms and also cheaper in terms of cost.”

AWS Glue is a serverless data integration service that makes it easy to discover, prepare, and combine data for analytics, machine learning, and application development. AWS Glue provides all of the capabilities needed for data integration so that you can start analyzing your data and putting it to use in minutes instead of months. AWS Glue provides both visual and code-based interfaces to make data integration easier. Users can easily find and access data using the AWS Glue Data Catalog.

AWS CodePipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your software. You can quickly model and configure the different stages of a software release process. CodePipeline automates the steps required to release your software changes continuously.

In this post, you will experience the integration of glue with CICD pipeline in cross accounts. Here I have created a s3, kms, codecommit repo and codepipeline for deployment of python script code in s3 bucket. Also created glue connection and glue job using cloudformation template.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv0mz295qrxmz64zz5f9.png)
The architecture diagram shows the overall deployment architecture with data flow, two aws account, code commit, code deploy, code pipeline, s3, cloudformation, kms, glue.

#Solution overview
The blog post consists of the following phases:
1. In Main Account, Create of CodeCommit Repo, S3 Bucket, KMS and CodePipeline
2. In Dev Account, Create of Glue Connection and Glue Job Using Cloudformation Template
3. Testing for Deployment of Script Python Code Using CodePipeline

##Phase 1: In Main Account, Create of CodeCommit Repo, S3 Bucket, KMS and CodePipeline
1. Open the console for creation of commit repo, s3 bucket with its encryption and adding bucket policy for cross account access. Also create a custom managed key and code pipeline. After creation of codepipeline will have a pipeline IAM role creation automatically.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yyn80cjdet5btgusfj5a.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9vb77d20gjkz90tgwk1.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/daj39i6b8e1gyril2qge.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9jc59tyeb008hu194n20.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2gp8eo6zxjntqcv2o7u.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hm4y0ezsmvy4q4wfui76.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2hweqt965z9xtdwifdk.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3bbwx7htgg0qvmhivjxt.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1f7m2zii916hxyiwwp6o.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5agn8jpuvoeijuw26gun.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vatbn8isfvdhopn4zoej.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/071jgra24blfjk4t8ovd.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/clell3vs338dc78jvbw9.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45vmfahgiq4vjxpy5ksu.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wj1lcysy7zjab36oehch.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86j8xeej2vsgtimgphjh.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z409u4c344cz60n1dj2e.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4bcho2x1ra849gth733b.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bpfpsj2z51kx27x0n0xr.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ohc977gqmi77tit0ac3p.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xceamjvcyobk4ukbsqsb.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xayl5ry9irtl8luovnnf.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lrhgmh73e19i0aeo9b8.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkz6rp9s3hj8d2he78uk.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l4y2w70dp0e4prtkjtmx.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v11nck6itcp0mk76iur9.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf2paullpku6cn1xtbg6.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1yjb7hz9zjnk3zrl6dr1.png)

##Phase 2: In Dev Account, Create of Glue Connection and Glue Job Using Cloudformation Template
1. Open the Cloudformation console, Create a glue connection and glue job with custom required parameters using template.yaml file.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v1ljy4vwqvks5puc2xlk.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vkakv0t69e0lwhxuct4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l21uekwlvxyjmrzdciwo.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdz1g5hm7z6e081q123r.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4jmgonw2b2gwo2267mh.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sjefi253vnev9oijrlo1.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ofxt0bfrwcmgyr9v0a5.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u44a3smu85a8lewsg8zi.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/se0pso5m640c2b1332hy.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f3vrxhhv102o4q3p788i.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qj7nkt0p988j676poifh.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/saq0cpnehufoteo3q8u4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpwekvuwfg725go9rtq5.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cjbwrshi4qq1pylm1003.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awvnobrlj5snlr9s5589.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sovgiptn5f87960y1wcs.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/468ly1cfywj0i15dh15e.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6k89uyt4ilfo13nbur3.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g16gnwgm2mw50rt1bb4l.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a56xdavztvyku12w9cny.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f88mhy8iv3p98neeayk4.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i18pjb4l4tn3d1sxgb3s.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b0711h2mlgkl2yo45ah6.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rdt8c9hsql74eiyxwsu.png)

##Phase 3: Testing for Deployment of Script Python Code Using CodePipeline
1. Python script code for glue job will be stored in commit repo and deployed to s3 bucket using code pipeline. Once the code deploy to s3, it will be reflected in the glue job created cross account. Also we can update the glue configuration by updating the cloudformation stack.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8xetiglteniqq95mdjfe.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3tncsaxbepzt8ak218ys.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hya03trcfx4atfg18uiz.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0hi9650l54w0q3y2e7tl.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e251fs1sg9rvsucz8p9n.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qq1hohi0cxu8dclfpf3u.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y4ynmfnzcei162c23gfh.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tvcvuox4h9acbluep0n8.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/az60edu734e552r37u18.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqy7uzucs4zvq0zpqx71.png)

#Clean-up
In Dev Account: Delete of cloudformation stack and IAM role. In Main Account: Delete of S3, KMS, IAM, codecommit repo and codepipeline.

#Pricing
I review the pricing and estimated cost of this example. 
Cost of CodeCommit = $0.0
Cost of Key Management Service = $1.00
Cost of Simple Storage Service = $0.01
Cost of Glue = $0.0
Total Cost = $(0.0 + 1.00 + 0.01 + 0.0) = $1.01

#Summary
In this post, I showed “how to do the integration of glue with CICD pipeline in cross accounts”.

For more details on AWS Glue, Checkout Get started AWS Glue, open the [AWS Glue console](https://ap-south-1.console.aws.amazon.com/glue/home?region=ap-south-1#). To learn more, read the [AWS Glue documentation](https://docs.aws.amazon.com/glue/?id=docs_gateway).

For more details on AWS CodePipeline, Checkout Get started AWS CodePipeline, open the [AWS CodePipeline console](https://ap-south-1.console.aws.amazon.com/codesuite/codepipeline/pipelines?region=ap-south-1&pipelines-meta=eyJmIjp7InRleHQiOiIifSwicyI6eyJwcm9wZXJ0eSI6InVwZGF0ZWQiLCJkaXJlY3Rpb24iOi0xfSwibiI6MTAsImkiOjB9). To learn more, read the [AWS CodePipeline documentation](https://docs.aws.amazon.com/codepipeline/?id=docs_gateway). 

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)