{"id":65161,"date":"2024-06-04T22:08:04","date_gmt":"2024-06-04T18:38:04","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/app-runner-with-cloudformation-aws-json-nodejs-java-433i\/"},"modified":"2024-06-04T22:08:04","modified_gmt":"2024-06-04T18:38:04","slug":"app-runner-with-cloudformation-aws-json-nodejs-java-433i","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/app-runner-with-cloudformation-aws-json-nodejs-java-433i\/","title":{"rendered":"\u0627\u062c\u0631\u0627\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \u0628\u0627 CloudFormation AWS (json\u060c nodejs\u060c java)"},"content":{"rendered":"<div data-article-id=\"1876348\" id=\"article-body\">\n<p>\u0628\u0631\u0627\u06cc \u062f\u0631\u06a9 \u0645\u062f\u0644 \u0645\u0639\u0645\u0627\u0631\u06cc \u0628\u0647 \u0645\u0642\u0627\u0644\u0647 \u0642\u0628\u0644\u06cc \u0645\u0631\u0627\u062c\u0639\u0647 \u06a9\u0646\u06cc\u062f:<br \/>https:\/\/dev.to\/huydanggdg\/migrate-heroku-to-aws-1d73<\/p>\n<p><\/p>\n<p><strong>1. \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0627\u062a\u0635\u0627\u0644 github<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feekfp5d06kumh06r4bjw.png\" alt=\"\u0627\u06cc\u062c\u0627\u062f \u062d\u0633\u0627\u0628 \u0647\u0627\u06cc \u0645\u062a\u0635\u0644\" loading=\"lazy\" width=\"499\" height=\"421\" title=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq39s4jauubm85hj89pu.png\" alt=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u062a\u0635\u0648\u06cc\u0631\" loading=\"lazy\" width=\"612\" height=\"255\" title=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faq2xvua128locjz6m8vr.png\" alt=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u062a\u0635\u0648\u06cc\u0631\" loading=\"lazy\" width=\"770\" height=\"397\" title=\"\"><\/p>\n<p><strong>2. \u0642\u0627\u0644\u0628 \u0641\u0627\u06cc\u0644 json \u0631\u0627 \u0628\u0631\u0627\u06cc Cloudformation \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f<\/strong><\/p>\n<p>\u0645\u062b\u0627\u0644 \u0628\u0631\u0627\u06cc nodejs<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>{\n  \"AWSTemplateFormatVersion\": \"2010-09-09\",\n  \"Resources\": {\n    \"AppRunnerService\": {\n      \"Type\": \"AWS::AppRunner::Service\",\n      \"Properties\": {\n        \"ServiceName\": \"client\",\n        \"SourceConfiguration\": {\n          \"AuthenticationConfiguration\": {\n            \"ConnectionArn\": \"arn:aws:apprunner:ap-northeast-1:68972488xxx:connection\/app\/xxxxxxxxxx\"\n          },\n          \"CodeRepository\": {\n            \"RepositoryUrl\": \"https:\/\/github.com\/huydanggdg\/client\",\n            \"SourceCodeVersion\": {\n              \"Type\": \"BRANCH\",\n              \"Value\": \"main\"\n            },\n            \"CodeConfiguration\": {\n              \"ConfigurationSource\": \"API\",\n              \"CodeConfigurationValues\": {\n                \"Runtime\": \"NODEJS_14\",\n        \"StartCommand\": \"npm run production\",\n                \"BuildCommand\": \"npm install\",               \n                \"Port\": \"8080\"\n              }\n            }\n          }\n        },\n        \"InstanceConfiguration\": {\n          \"Cpu\": \"1024\",\n          \"Memory\": \"2048\"\n        }\n      }\n    }\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0645\u062b\u0627\u0644 \u0628\u0631\u0627\u06cc \u062c\u0627\u0648\u0627<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>{\n  \"AWSTemplateFormatVersion\": \"2010-09-09\",\n  \"Resources\": {\n    \"AppRunnerService\": {\n      \"Type\": \"AWS::AppRunner::Service\",\n      \"Properties\": {\n        \"ServiceName\": \"java-main\",\n        \"SourceConfiguration\": {\n          \"AuthenticationConfiguration\": {\n            \"ConnectionArn\": \"arn:aws:apprunner:ap-northeast-1:6897248xxxx:connection\/app\/xxxxxxx\"\n          },\n          \"CodeRepository\": {\n            \"RepositoryUrl\": \"https:\/\/github.com\/huydanggdg\/java-main\",\n            \"SourceCodeVersion\": {\n              \"Type\": \"BRANCH\",\n              \"Value\": \"main\"\n            },\n            \"CodeConfiguration\": {\n              \"ConfigurationSource\": \"API\",\n              \"CodeConfigurationValues\": {\n                \"Runtime\": \"CORRETTO_8\",\n        \"StartCommand\": \"java -Xms256m -jar target\/gms_agm.jar .\",\n                \"BuildCommand\": \"mvn package\",               \n                \"Port\": \"3020\"\n              }\n            }\n          }\n        },\n        \"InstanceConfiguration\": {\n          \"Cpu\": \"2048\",\n          \"Memory\": \"4096\"\n        }\n      }\n    }\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p>\u0645\u062b\u0627\u0644 \u0628\u0631\u0627\u06cc \u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>{\n  \"AWSTemplateFormatVersion\": \"2010-09-09\",\n  \"Description\": \"RDS PostgreSQL with Auto-Created VPC for Singer\",\n  \"Parameters\": {\n    \"DBPassword\": {\n      \"Type\": \"String\",\n      \"NoEcho\": true,\n      \"Description\": \"Password for the PostgreSQL database\"\n    }\n  },\n  \"Resources\": {\n    \"VPC\": {\n      \"Type\": \"AWS::EC2::VPC\",\n      \"Properties\": {\n        \"CidrBlock\": \"10.0.0.0\/16\",\n        \"EnableDnsSupport\": true,\n        \"EnableDnsHostnames\": true,\n        \"Tags\": [{ \"Key\": \"Name\", \"Value\": \"SingerVPC\" }]\n      }\n    },\n    \"InternetGateway\": {\n      \"Type\": \"AWS::EC2::InternetGateway\",\n      \"Properties\": {\n        \"Tags\": [{ \"Key\": \"Name\", \"Value\": \"SingerIGW\" }]\n      }\n    },\n    \"VPCGatewayAttachment\": {\n      \"Type\": \"AWS::EC2::VPCGatewayAttachment\",\n      \"Properties\": {\n        \"VpcId\": { \"Ref\": \"VPC\" },\n        \"InternetGatewayId\": { \"Ref\": \"InternetGateway\" }\n      }\n    },\n    \"SubnetGroup\": {\n      \"Type\": \"AWS::RDS::DBSubnetGroup\",\n      \"Properties\": {\n        \"DBSubnetGroupDescription\": \"Subnets for Singer RDS\",\n        \"SubnetIds\": [\n          { \"Ref\": \"PublicSubnet1\" },\n          { \"Ref\": \"PublicSubnet2\" }\n        ]\n      }\n    },\n    \"PublicSubnet1\": {\n      \"Type\": \"AWS::EC2::Subnet\",\n      \"Properties\": {\n        \"VpcId\": { \"Ref\": \"VPC\" },\n        \"CidrBlock\": \"10.0.0.0\/24\",\n        \"AvailabilityZone\": { \"Fn::Select\": [0, { \"Fn::GetAZs\": \"\" }] },\n        \"MapPublicIpOnLaunch\": true,\n        \"Tags\": [{ \"Key\": \"Name\", \"Value\": \"SingerPublicSubnet1\" }]\n      }\n    },\n    \"PublicSubnet2\": {\n      \"Type\": \"AWS::EC2::Subnet\",\n      \"Properties\": {\n        \"VpcId\": { \"Ref\": \"VPC\" },\n        \"CidrBlock\": \"10.0.1.0\/24\",\n        \"AvailabilityZone\": { \"Fn::Select\": [1, { \"Fn::GetAZs\": \"\" }] },\n        \"MapPublicIpOnLaunch\": true,\n        \"Tags\": [{ \"Key\": \"Name\", \"Value\": \"SingerPublicSubnet2\" }]\n      }\n    },\n    \"PostgreSQLInstance\": {\n      \"Type\": \"AWS::RDS::DBInstance\",\n      \"Properties\": {\n        \"AllocatedStorage\": \"20\",\n        \"DBInstanceClass\": \"db.t3.micro\",\n        \"Engine\": \"postgres\",\n        \"EngineVersion\": \"14\",\n        \"MasterUsername\": \"admin\",\n        \"MasterUserPassword\": { \"Ref\": \"DBPassword\" },\n        \"DBName\": \"singer_db\",\n        \"PubliclyAccessible\": false,\n        \"DBSubnetGroupName\": { \"Ref\": \"SubnetGroup\" }\n      }\n    }\n  },\n  \"Outputs\": {\n    \"PostgreSQLInstanceEndpoint\": {\n      \"Description\": \"Endpoint for the PostgreSQL instance\",\n      \"Value\": { \"Fn::GetAtt\": [\"PostgreSQLInstance\", \"Endpoint.Address\"] }\n    }\n  }\n}\n<\/code><\/pre>\n<div class=\"highlight__panel js-actions-panel\">\n<div class=\"highlight__panel-action js-fullscreen-code-action\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-on\"><title>\u0648\u0627\u0631\u062f \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M16 3h6v6h-2V5h-4V3zM2 3h6v2H4v4H2V3zm18 16v-4h2v6h-6v-2h4zM4 19h4v2H2v-6h2v4z\"\/>\n<\/svg><\/p>\n<p>    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" class=\"highlight-action crayons-icon highlight-action--fullscreen-off\"><title>\u0627\u0632 \u062d\u0627\u0644\u062a \u062a\u0645\u0627\u0645 \u0635\u0641\u062d\u0647 \u062e\u0627\u0631\u062c \u0634\u0648\u06cc\u062f<\/title>\n    <path d=\"M18 7h4v2h-6V3h2v4zM8 9H2V7h4V3h2v6zm10 8v4h-2v-6h6v2h-4zM8 15v6H6v-4H2v-2h6z\"\/>\n<\/svg><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><strong>3. \u06a9\u062f \u0631\u0627 \u0627\u062c\u0631\u0627 \u06a9\u0646\u06cc\u062f<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy919wb7t6mw8xh9freug.png\" alt=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u062a\u0635\u0648\u06cc\u0631\" loading=\"lazy\" width=\"800\" height=\"372\" title=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbnca31er9i0x38d1un81.png\" alt=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u062a\u0635\u0648\u06cc\u0631\" loading=\"lazy\" width=\"800\" height=\"233\" title=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc7pby2izb6p1x16e6fnb.png\" alt=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u062a\u0635\u0648\u06cc\u0631\" loading=\"lazy\" width=\"800\" height=\"273\" title=\"\"><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/media.dev.to\/cdn-cgi\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft0w342vmzc993l9dq682.png\" alt=\"\u062a\u0648\u0636\u06cc\u062d\u0627\u062a \u062a\u0635\u0648\u06cc\u0631\" loading=\"lazy\" width=\"800\" height=\"186\" title=\"\"><br \/>\u06af\u0632\u06cc\u0646\u0647 \u067e\u06cc\u0634 \u0641\u0631\u0636 \u0648 \u0628\u0631\u0631\u0633\u06cc => \u0627\u0631\u0633\u0627\u0644<\/p>\n<p><strong>4. \u0628\u0631\u0631\u0633\u06cc \u062e\u062f\u0645\u0627\u062a<\/strong><br \/><strong>5.\u067e\u0634\u062a\u0647 \u0631\u0627 \u062d\u0630\u0641 \u06a9\u0646\u06cc\u062f<\/strong> => \u0633\u0631\u0648\u06cc\u0633 \u067e\u0627\u06a9\u0633\u0627\u0632\u06cc \u062e\u0648\u062f\u06a9\u0627\u0631 AWS<\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0628\u0631\u0627\u06cc \u062f\u0631\u06a9 \u0645\u062f\u0644 \u0645\u0639\u0645\u0627\u0631\u06cc \u0628\u0647 \u0645\u0642\u0627\u0644\u0647 \u0642\u0628\u0644\u06cc \u0645\u0631\u0627\u062c\u0639\u0647 \u06a9\u0646\u06cc\u062f:https:\/\/dev.to\/huydanggdg\/migrate-heroku-to-aws-1d73 1. \u0631\u0627\u0647 \u0627\u0646\u062f\u0627\u0632\u06cc \u0627\u062a\u0635\u0627\u0644 github 2. \u0642\u0627\u0644\u0628 \u0641\u0627\u06cc\u0644 json \u0631\u0627 \u0628\u0631\u0627\u06cc Cloudformation \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u062f \u0645\u062b\u0627\u0644 \u0628\u0631\u0627\u06cc nodejs { &#8220;AWSTemplateFormatVersion&#8221;: &#8220;2010-09-09&#8221;, &#8220;Resources&#8221;: { &#8220;AppRunnerService&#8221;: { &#8220;Type&#8221;: &#8220;AWS::AppRunner::Service&#8221;, &#8220;Properties&#8221;: { &#8220;ServiceName&#8221;: &#8220;client&#8221;, &#8220;SourceConfiguration&#8221;: { &#8220;AuthenticationConfiguration&#8221;: { &#8220;ConnectionArn&#8221;: &#8220;arn:aws:apprunner:ap-northeast-1:68972488xxx:connection\/app\/xxxxxxxxxx&#8221; }, &#8220;CodeRepository&#8221;: { &#8220;RepositoryUrl&#8221;: &#8220;https:\/\/github.com\/huydanggdg\/client&#8221;, &#8220;SourceCodeVersion&#8221;: { &#8220;Type&#8221;: &#8220;BRANCH&#8221;, &#8220;Value&#8221;: &hellip;<\/p>\n","protected":false},"author":2,"featured_media":65162,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-65161","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/65161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=65161"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/65161\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/65162"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=65161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=65161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=65161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}