<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yinlin Chen</title>
    <description>The latest articles on DEV Community by Yinlin Chen (@yinlinchen).</description>
    <link>https://dev.to/yinlinchen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F333624%2Fa5d58243-f9a0-4da7-81bf-e9dca42663b3.jpeg</url>
      <title>DEV Community: Yinlin Chen</title>
      <link>https://dev.to/yinlinchen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yinlinchen"/>
    <language>en</language>
    <item>
      <title>AWS Amplify AppSync GraphQL custom resolver examples</title>
      <dc:creator>Yinlin Chen</dc:creator>
      <pubDate>Wed, 09 Jun 2021 02:39:22 +0000</pubDate>
      <link>https://dev.to/yinlinchen/aws-amplify-appsync-graphql-custom-resolver-examples-1ek4</link>
      <guid>https://dev.to/yinlinchen/aws-amplify-appsync-graphql-custom-resolver-examples-1ek4</guid>
      <description>&lt;p&gt;AWS Amplify is great! It handles AppSync backend with AWS resources, like DynamoDB, ElasticSearch, etc for you. However, sometimes these default generated GraphQL schema and resolvers are not fulfill our business need. We create an &lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql" rel="noopener noreferrer"&gt;Amplify Appsync GraphQL&lt;/a&gt; GitHub repo to document some of the custom AppSync Resolver.&lt;/p&gt;

&lt;p&gt;There are three steps to create your custom resolvers using AWS Amplify CLI&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Step1: Add custom type to the schema&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add custom &lt;code&gt;Query&lt;/code&gt;, &lt;code&gt;Mutation&lt;/code&gt; or &lt;code&gt;Subscription&lt;/code&gt; type to your schema.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Step2: Create custom resolver template&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request and response template should be located in &lt;code&gt;&amp;lt;project-root&amp;gt;/amplify/backend/api/&amp;lt;api-name&amp;gt;/resolvers&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;Graphql Transformer follows &lt;code&gt;&amp;lt;TypeName&amp;gt;.&amp;lt;FieldName&amp;gt;.&amp;lt;req/res&amp;gt;.vlt&lt;/code&gt; as convention to name the resolvers.

&lt;ul&gt;
&lt;li&gt;Request template: &lt;code&gt;Query.myCustomQuery.req.vtl&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Response template: &lt;code&gt;Query.myCustomQuery.res.vtl&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;Step3: Add resolvers resource by creating a custom stack&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; By default, there is a file called &lt;code&gt;CustomResources.json&lt;/code&gt; in &lt;code&gt;&amp;lt;project-root&amp;gt;/amplify/backend/api/&amp;lt;api-name&amp;gt;/stacks&lt;/code&gt; directory of your API.&lt;/li&gt;
&lt;li&gt;Example: &lt;a href="//examples/CustomResource.json"&gt;CustomResource.json&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Currently, we provides these examples:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/basic.md" rel="noopener noreferrer"&gt;Basic models&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/search.md" rel="noopener noreferrer"&gt;Enable basic search&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/fuzzysearch.md" rel="noopener noreferrer"&gt;Fuzzy search&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/interfacetype.md" rel="noopener noreferrer"&gt;Query for Interface type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/andoroperation.md" rel="noopener noreferrer"&gt;Search with AND/OR operations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/multifields.md" rel="noopener noreferrer"&gt;Multi-fields search&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/searchableinput.md" rel="noopener noreferrer"&gt;Custom searchable input&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/amplify-appsync-graphql/blob/master/docs/uniontype.md" rel="noopener noreferrer"&gt;Query for Union type&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can deploy the entire example app here:&lt;br&gt;
&lt;a href="https://console.aws.amazon.com/amplify/home#/deploy?repo=https://github.com/yinlinchen/amplify-appsync-graphql" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Foneclick.amplifyapp.com%2Fbutton.svg" alt="amplifybutton"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We hopes these examples help! Please feel free to contribute more custom examples to us and make it better!&lt;/p&gt;

</description>
      <category>amplify</category>
      <category>aws</category>
      <category>graphql</category>
      <category>appsync</category>
    </item>
    <item>
      <title>A Thumbnail Creator Serverless application</title>
      <dc:creator>Yinlin Chen</dc:creator>
      <pubDate>Sun, 09 May 2021 00:24:16 +0000</pubDate>
      <link>https://dev.to/yinlinchen/a-thumbnail-creator-serverless-application-74f</link>
      <guid>https://dev.to/yinlinchen/a-thumbnail-creator-serverless-application-74f</guid>
      <description>&lt;h1&gt;
  
  
  Thumbnail Creator
&lt;/h1&gt;

&lt;p&gt;A Thumbnail Creator Serverless application. This application automatically creates a thumbnail for image, PDF, and video files. Once this application is deployed, you only need to upload files into an S3 bucket and all the thumbnails will be automatically created and saved in the result S3 bucket.&lt;/p&gt;

&lt;p&gt;When a file is uploaded to an S3 bucket, the application will detect the file type, create a thumbnail, and save it to another S3 bucket. &lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fyinlinchen%2Fthumbnail_creator%2Fraw%2Fmaster%2Fimages%2Foverview.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fyinlinchen%2Fthumbnail_creator%2Fraw%2Fmaster%2Fimages%2Foverview.png" title="Overview" alt="Overview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Upload image, video, or pdf file to the S3 upload bucket&lt;/li&gt;
&lt;li&gt;Thumbnail files will be created and stored in the S3 result bucket&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Lambda Function
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="//apps/app.py"&gt;app.py&lt;/a&gt;: Create a thumbnail for the image, pdf, and video file that uploaded to an S3 bucket&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.tosharedutils/"&gt;sharedutils&lt;/a&gt;: a custom Lambda Layer &lt;a href="https://github.com/h2non/filetype.py" rel="noopener noreferrer"&gt;filetype&lt;/a&gt; - Python package to infer binary file types&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: This application uses the below three custom Lambda Layers and you must deploy these Lambda Layers before deploying this application.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://serverlessrepo.aws.amazon.com/applications/us-east-1/154387959412/ghostscript-lambda-layer" rel="noopener noreferrer"&gt;ghostscript&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:145266761615:applications~image-magick-lambda-layer" rel="noopener noreferrer"&gt;imagemagic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://serverlessrepo.aws.amazon.com/applications/us-east-1/145266761615/ffmpeg-lambda-layer" rel="noopener noreferrer"&gt;ffmpeg&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;ps. Since it uses Lambda temporary storage with a fixed size of 512MB. So you may need to consider using Amazon EFS for  Lambda in order to process large-size files. &lt;a href="https://aws.amazon.com/blogs/compute/using-amazon-efs-for-aws-lambda-in-your-serverless-applications/" rel="noopener noreferrer"&gt;Learn more&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployments
&lt;/h2&gt;

&lt;p&gt;You can deploy this application directly from the AWS Serverless Application repository, on-click button CloudFormation deploy, or using SAM CLI. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For more information, check out the &lt;a href="https://serverlessrepo.aws.amazon.com/applications/us-east-1/307821251221/Thumbnail-Creator" rel="noopener noreferrer"&gt;Thumbnail-Creator&lt;/a&gt; application in the Serverless App Repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For manual deployments and custom builds through CloudFormation or SAM, see below sections.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deploy Thumbnail Creator application using CloudFormation stack
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1: Launch CloudFormation stack
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?&amp;amp;templateURL=https://yc-deploy.s3.amazonaws.com/69a73d8311ce2a47f0edf3a45868f8c0.template" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.rawgit.com%2Fbuildkite%2Fcloudformation-launch-stack-button-svg%2Fmaster%2Flaunch-stack.svg" alt="Launch Stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;em&gt;Next&lt;/em&gt; to continue&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Specify stack details
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Example value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Stack name&lt;/td&gt;
&lt;td&gt;any valid stack name&lt;/td&gt;
&lt;td&gt;filethumbnail&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ImageMagickLayer&lt;/td&gt;
&lt;td&gt;ImageMagick Lambda Layer ARN&lt;/td&gt;
&lt;td&gt;arn:aws:lambda:us-east-1::layer:image-magick:1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GhostscriptLayer&lt;/td&gt;
&lt;td&gt;Ghostscript Lambda Layer ARN&lt;/td&gt;
&lt;td&gt;arn:aws:lambda:us-east-1::layer:image-magick:1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FfmpegLayer&lt;/td&gt;
&lt;td&gt;Ffmpeg Lambda Layer ARN&lt;/td&gt;
&lt;td&gt;arn:aws:lambda:us-east-1::layer:image-magick:1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ConversionFileType&lt;/td&gt;
&lt;td&gt;a valid file type&lt;/td&gt;
&lt;td&gt;jpg&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ConversionMimeType&lt;/td&gt;
&lt;td&gt;a valid mime type&lt;/td&gt;
&lt;td&gt;image/jpeg&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ThumbnailWidth&lt;/td&gt;
&lt;td&gt;a valid number&lt;/td&gt;
&lt;td&gt;150&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Step 3: Configure stack options
&lt;/h4&gt;

&lt;p&gt;Leave it as is and click &lt;strong&gt;Next&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 4: Review
&lt;/h4&gt;

&lt;p&gt;Make sure all checkboxes under Capabilities section are &lt;strong&gt;CHECKED&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;em&gt;Create stack&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy Thumbnail Creator application using SAM CLI
&lt;/h3&gt;

&lt;p&gt;To use the SAM CLI, you need the following tools.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SAM CLI - &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html" rel="noopener noreferrer"&gt;Install the SAM CLI&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.python.org/downloads/" rel="noopener noreferrer"&gt;Python 3 installed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Docker - &lt;a href="https://hub.docker.com/search/?type=edition&amp;amp;offering=community" rel="noopener noreferrer"&gt;Install Docker community edition&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To build and deploy your application for the first time, run the following in your shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sam build &lt;span class="nt"&gt;--use-container&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above command will build the source of the application. The SAM CLI installs dependencies defined in &lt;code&gt;requirements.txt&lt;/code&gt;, creates a deployment package, and saves it in the &lt;code&gt;.aws-sam/build&lt;/code&gt; folder.&lt;/p&gt;

&lt;p&gt;To package the application, run the following in your shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sam package &lt;span class="nt"&gt;--output-template-file&lt;/span&gt; packaged.yaml &lt;span class="nt"&gt;--s3-bucket&lt;/span&gt; BUCKETNAME &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above command will package the application and upload it to the S3 bucket you specified.&lt;/p&gt;

&lt;p&gt;Run the following in your shell to deploy the application to AWS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sam deploy &lt;span class="nt"&gt;--template-file&lt;/span&gt; packaged.yaml &lt;span class="nt"&gt;--stack-name&lt;/span&gt; STACKNAME &lt;span class="nt"&gt;--s3-bucket&lt;/span&gt; BUCKETNAME &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nt"&gt;--parameter-overrides&lt;/span&gt; &lt;span class="s1"&gt;'ImageMagickLayer=layerARN GhostscriptLayer=layerARN FfmpegLayer=layerARN ThumbnailWidth=150'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
 &lt;span class="nt"&gt;--capabilities&lt;/span&gt; CAPABILITY_IAM &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the cloudformation resource like below&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fyinlinchen%2Fthumbnail_creator%2Fraw%2Fmaster%2Fimages%2Fstack_output.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fyinlinchen%2Fthumbnail_creator%2Fraw%2Fmaster%2Fimages%2Fstack_output.png" title="Resources" alt="Resources"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Upload files to the &lt;code&gt;UploadBucket&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Thumbnail files will be created and stored in the &lt;code&gt;ResultsBucket&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Cleanup
&lt;/h2&gt;

&lt;p&gt;To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws cloudformation delete-stack &lt;span class="nt"&gt;--stack-name&lt;/span&gt; stackname
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>thumbnail</category>
      <category>lambda</category>
      <category>aws</category>
      <category>serverless</category>
    </item>
    <item>
      <title>AWS Amplify Pull-Request Previews for Public GitHub repository</title>
      <dc:creator>Yinlin Chen</dc:creator>
      <pubDate>Sun, 13 Sep 2020 15:25:39 +0000</pubDate>
      <link>https://dev.to/yinlinchen/aws-amplify-pull-request-previews-for-public-github-repository-11nc</link>
      <guid>https://dev.to/yinlinchen/aws-amplify-pull-request-previews-for-public-github-repository-11nc</guid>
      <description>&lt;h3&gt;
  
  
  My Workflow
&lt;/h3&gt;

&lt;p&gt;AWS Amplify Pull-Request Previews currently only supports private GitHub repository. This &lt;code&gt;amplify-preview-actions&lt;/code&gt; GitHub action enables the ability to deploy AWS Amplify Pull-Request Previews for your open source and public GitHub repository.&lt;/p&gt;

&lt;p&gt;With this &lt;code&gt;amplify-preview-actions&lt;/code&gt; GitHub action, you can define your own rule to deploy the Pull-Request branch to the AWS Amplify console app page for a preview. For example, you can setup a rule only a pull request is labeled with &lt;code&gt;Ready for review&lt;/code&gt; and is assigned to a reviewer; and clean up the previews after the pull request is merged or closed. &lt;/p&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;DIY Deployments&lt;/p&gt;

&lt;h3&gt;
  
  
  Yaml File or Link to Code
&lt;/h3&gt;

&lt;h4&gt;
  
  
  GitHub Page
&lt;/h4&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/yinlinchen"&gt;
        yinlinchen
      &lt;/a&gt; / &lt;a href="https://github.com/yinlinchen/amplify-preview-actions"&gt;
        amplify-preview-actions
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      This action deploys your AWS Amplify pull request preview for your public repository
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
amplify-preview-actions&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://github.com/ambientlight/amplify-cli-action/releases"&gt;&lt;img src="https://camo.githubusercontent.com/03b3dfc84921f0662516e12615c5387296669d29/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f79696e6c696e6368656e2f616d706c6966792d707265766965772d616374696f6e733f696e636c7564655f70726572656c6561736573" alt="RELEASE"&gt;&lt;/a&gt;
&lt;a href="https://github.com/yinlinchen/amplify-preview-actions/blob/master/LICENSE"&gt;&lt;img src="https://camo.githubusercontent.com/27068d5e548197a10b1e455283c925edd726389c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f79696e6c696e6368656e2f616d706c6966792d707265766965772d616374696f6e73" alt="LICENSE"&gt;&lt;/a&gt;
&lt;a href="https://github.com/yinlinchen/amplify-preview-actions/issues"&gt;&lt;img src="https://camo.githubusercontent.com/2b2caa8856529560edb77f75689f7ab11c1baa84/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f79696e6c696e6368656e2f616d706c6966792d707265766965772d616374696f6e73" alt="ISSUES"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;AWS Amplify Pull-Request Previews currently only supports private GitHub repository. This &lt;code&gt;amplify-preview-actions&lt;/code&gt; GitHub action enables the ability to deploy AWS Amplify Pull-Request Previews for your open source and public GitHub repository.&lt;/p&gt;
&lt;p&gt;With this &lt;code&gt;amplify-preview-actions&lt;/code&gt; GitHub action, you can define your own rule to deploy the Pull-Request branch to the AWS Amplify console app page for a preview. For example, you can setup a rule only a pull request is labeled with &lt;code&gt;Ready for review&lt;/code&gt; and is assigned to a reviewer; and clean up the previews after the pull request is merged or closed.&lt;/p&gt;
&lt;h2&gt;
Getting Started&lt;/h2&gt;
&lt;p&gt;You can include the action in your workflow as &lt;code&gt;actions/amplify-preview-actions@master&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;
Basic &lt;code&gt;workflow.yml&lt;/code&gt; Example&lt;/h3&gt;
&lt;p&gt;Deploy a PR preview branch to the Amplify console App page (not the Previews page) after a reviewer is assigned.&lt;/p&gt;
&lt;p&gt;Place in a &lt;code&gt;.yml&lt;/code&gt; file such as this one in your &lt;code&gt;.github/workflows&lt;/code&gt; folder. &lt;a href="https://help.github.com/en/articles/workflow-syntax-for-github-actions"&gt;Refer to the documentation on workflow YAML&lt;/a&gt;…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/yinlinchen/amplify-preview-actions"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h4&gt;
  
  
  GitHub Marketplace page
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/marketplace/actions/amplify-preview-actions"&gt; &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dubAhMKl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rhquiwemnzuq014e1ngh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Installation
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- name: amplify-preview-actions
  uses: yinlinchen/amplify-preview-actions@v1.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  An example of how to use the Action:
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: 'Amplify PR Preview'
on:
  pull_request:
    types: [review_requested]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master

    - name: set branchname env
      id: setenvname
      run: |
        # use GITHUB_HEAD_REF that is set to PR source branch
        echo "##[set-output name=setbranchname;]$(echo ${GITHUB_HEAD_REF})"

    - name: deploy PR preview
      uses: yinlinchen/amplify-preview-actions@master
      with:
        branch_name: ${{ steps.setenvname.outputs.setbranchname }}
        amplify_command: deploy
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        AmplifyAppId: ${{ secrets.AmplifyAppId }}
        BackendEnvARN: ${{ secrets.BackendEnvARN }}
        AWS_REGION: 'us-east-1'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Additional Resources / Info
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Screenshots:
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r_8LmTh_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/yinlinchen/amplify-preview-actions/raw/master/demo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r_8LmTh_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/yinlinchen/amplify-preview-actions/raw/master/demo.gif" width="80%"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Open source projects that are using this workflow:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/yinlinchen/bookapp"&gt;Amplify workshop bookapp demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/VTUL/dlp-access"&gt;DLP Access Website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/SimplQ/simplQ-frontend"&gt;SimplQ&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>actionshackathon</category>
      <category>aws</category>
      <category>serverless</category>
      <category>github</category>
    </item>
    <item>
      <title>Deploy a Lambda function triggered by S3 event using CodePipeline </title>
      <dc:creator>Yinlin Chen</dc:creator>
      <pubDate>Fri, 03 Apr 2020 14:31:22 +0000</pubDate>
      <link>https://dev.to/yinlinchen/deploy-a-lambda-function-triggered-by-s3-event-using-codepipeline-24c3</link>
      <guid>https://dev.to/yinlinchen/deploy-a-lambda-function-triggered-by-s3-event-using-codepipeline-24c3</guid>
      <description>&lt;p&gt;This post demonstrates how to deploy a Lambda function hosted in the GitHub using CodePipeline. We use one of our projects &lt;a href="https://github.com/vt-digital-libraries-platform/S3toDDB"&gt;S3toDDB&lt;/a&gt; as an example. The Lambda function in this project receives event notifications from a S3 bucket, process data in files, and create or update data in DynamoDB. Please see project &lt;a href="https://github.com/vt-digital-libraries-platform/S3toDDB"&gt;README&lt;/a&gt; for details.    &lt;/p&gt;

&lt;p&gt;Go to the &lt;a href="https://console.aws.amazon.com/codesuite/codepipeline/pipelines?region=us-east-1"&gt;CodePipeline&lt;/a&gt; console and select “create pipeline”. &lt;/p&gt;

&lt;p&gt;&lt;b&gt;In the Step 1:&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter a pipeline name&lt;/li&gt;
&lt;li&gt;Under service role, select new service role and enter a role name, click Next button.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sl5sjG96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7e117rhmyp4du3xlcipa.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;b&gt;In the Step 2:&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select GitHub as the source provider&lt;/li&gt;
&lt;li&gt;Select target GitHub repository&lt;/li&gt;
&lt;li&gt;Select target branch
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hDIXf5Ie--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o4oz9esjbdcc6cqhgjqt.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;b&gt;In the step 3:&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select AWS CodeBuild&lt;/li&gt;
&lt;li&gt;Select create project
In the create build project popup window&lt;/li&gt;
&lt;li&gt;Enter a project name&lt;/li&gt;
&lt;li&gt;Select Ubuntu as the Operating system&lt;/li&gt;
&lt;li&gt;Select "Standard"&lt;/li&gt;
&lt;li&gt;Select "image:2.0"&lt;/li&gt;
&lt;li&gt;select New service role and role name
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E4kRQTJG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9vdl7ejodp1fh0tnxunn.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;go to IAM console and add a

&lt;code&gt;PutObject&lt;/code&gt;

permission to the S3 bucket as specified in the &lt;a href="https://github.com/vt-digital-libraries-platform/S3toDDB/blob/master/buildspec.yml#L11"&gt;buildspec.yml&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "Effect": "Allow",
        "Resource": [
            "arn:aws:s3:::bucketname/*"
        ],
        "Action": [
            "s3:PutObject"
        ]
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;b&gt;In the step 4:&lt;/b&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select AWS Cloudformation&lt;/li&gt;
&lt;li&gt;Under the action mode, select “create or update a stack”&lt;/li&gt;
&lt;li&gt;Enter a stack name&lt;/li&gt;
&lt;li&gt;Under the Artifact name, select “BuildArctifact”. Enter “packaged-template.yml” in the File name&lt;/li&gt;
&lt;li&gt;Under the Capabilities, select “CAPABILITY_AUTO_EXPAND” and “CAPABILITY_IAM”&lt;/li&gt;
&lt;li&gt;Select a role name. (Note. You need to create a role with the necessary permissions)&lt;/li&gt;
&lt;li&gt;Under the advanced, supply the &lt;a href="https://github.com/vt-digital-libraries-platform/S3toDDB#codedeploy-parameter-override"&gt;Parameter Override&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"APPIMGROOTPATH":"https://img.cloud.lib.vt.edu/iawa/","BibliographicCitation":"Researchers wishing to cite this collection should include the following information: - Special Collections, Virginia Polytechnic Institute and State University, Blacksburg, Va.","CollectionCategory":"IAWA","DYNOCollectionTABLE":"Collection-xxxxxx","DYNOArchiveTABLE":"Archive-yyyyyy","NOIDNAA":"53696","NOIDScheme":"ark:/","NOIDTemplate":"eeddeede","REGION":"us-east-1","RightsHolder":"Special Collections, University Libraries, Virginia Tech","RightsStatement":"Permission to publish material from the must be obtained from University Libraries Special Collections, Virginia Tech.","S3BucketName":"iawa-s3csv","LambdaLayerParameter":"arn:aws:lambda:us-east-1:xxxxxxxxx:layer:iawa-layer:1"}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UnokFE41--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ukqbjozwgibprh7f38tz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UnokFE41--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ukqbjozwgibprh7f38tz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it, click the next button and start the codepipeline. If everything works, it should show succeed in every stages. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NFFLMoMY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gyw8m7wiakw0l023u7py.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NFFLMoMY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gyw8m7wiakw0l023u7py.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>lambda</category>
      <category>codepipeline</category>
    </item>
  </channel>
</rss>
