<?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: Vinícius A. dos Santos</title>
    <description>The latest articles on DEV Community by Vinícius A. dos Santos (@viniciusvasti).</description>
    <link>https://dev.to/viniciusvasti</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%2F577227%2F60868981-31ee-4a6e-ad81-c079d5a6196f.jpg</url>
      <title>DEV Community: Vinícius A. dos Santos</title>
      <link>https://dev.to/viniciusvasti</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/viniciusvasti"/>
    <language>en</language>
    <item>
      <title>Software Engineering vs Video Games</title>
      <dc:creator>Vinícius A. dos Santos</dc:creator>
      <pubDate>Mon, 01 Mar 2021 15:46:25 +0000</pubDate>
      <link>https://dev.to/viniciusvasti/software-engineering-vs-video-games-5g4c</link>
      <guid>https://dev.to/viniciusvasti/software-engineering-vs-video-games-5g4c</guid>
      <description>&lt;p&gt;Well, since I was a kid, I loved to play video games. Started with Mega Drive, playing Sonic. Then my brother earned a PlayStation, I loved to play "Crash Bandicoot". The consoles generation were evolving and I followed until Xbox 360.&lt;/p&gt;

&lt;p&gt;I don't play video games anymore.&lt;br&gt;
I was thinking about that and realized that I don't miss it, but I didn't loose that feeling and I know why that happens.&lt;/p&gt;

&lt;p&gt;What I liked on video games was to complete missions, achieve the best results possible.&lt;br&gt;
Do you know those kind of games that you can finish doing about 70 percent of you could do on the game stages? To achieve 100 percent of completion, you needed to do some side tasks, take all the gold coins scattered through the stage, and things like that.&lt;br&gt;
I was the kind of player that wished to reach 100 percent of completion. It wasn't always possible (after all, sometimes it's so difficult and time consuming that it doesn't worth it), but I was always trying to make it. &lt;/p&gt;

&lt;p&gt;I reach those feelings I felt playing video games while developing software.&lt;br&gt;
Whenever a suite of unit tests passes, a request of a Rest API I implemented works, the Stakeholders' feed-backs are positive, it's like completing a video game stage, defeating a boss, winning the game.&lt;br&gt;
It's so satisfying...&lt;br&gt;
Also, I don't aim to achieve 70 percent completion, that is, delivering a feature that works in a functional way. I want 100 percent. I want the cleanest code, the most secure level, the best performance possible. But by the same way I used to think while playing, sometimes it doesn't worth the effort and time consumed to achieve this.&lt;br&gt;
I have in mind things like time-to-market, agility and generating value for company in order to decide when it's worth waste more time trying to achieve 100 percent.&lt;/p&gt;

&lt;p&gt;Does it makes sense for you?&lt;/p&gt;

</description>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>When to change a Rest API version</title>
      <dc:creator>Vinícius A. dos Santos</dc:creator>
      <pubDate>Fri, 12 Feb 2021 21:04:43 +0000</pubDate>
      <link>https://dev.to/viniciusvasti/when-to-change-an-rest-api-version-3ba8</link>
      <guid>https://dev.to/viniciusvasti/when-to-change-an-rest-api-version-3ba8</guid>
      <description>&lt;p&gt;Hi, everyone!&lt;br&gt;
If are familiar with de concepts of API, you know that most of time it's built to other developers to consume it. It doesn't matter the kind of API: HTTP API's, libs, packages, etc. Either it is a external API, for anyone in the world who ask you for an API key or an internal API for other teams inside same company.&lt;br&gt;&lt;br&gt;
Yesterday a colleague from the company I'm currently employed complained about a breaking change in a Rest API his application consumes from another team.&lt;br&gt;&lt;br&gt;
He wasn't advised about the change and his application broke in production.&lt;br&gt;&lt;br&gt;
Actually, a breaking changing in a Rest API shouldn't happens even when advising all the consumers.&lt;br&gt;&lt;br&gt;
The risk is to high, you may forget someone. Besides that, everyone should synchronize the change so the application users have no impact.&lt;/p&gt;

&lt;p&gt;So I'm listing some rules to guide us about when to generate a new version of a Rest API instead of simply changing it in the current version.&lt;/p&gt;




&lt;h3&gt;
  
  
  Changes that requires generating a new API version
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Removing a resource. E.g. &lt;code&gt;api.com/store&lt;/code&gt; is been removed;&lt;/li&gt;
&lt;li&gt;Removing a method of a resource. E.g. &lt;code&gt;PUT&lt;/code&gt; on &lt;code&gt;api.com/store/products/123&lt;/code&gt; is been removed;&lt;/li&gt;
&lt;li&gt;Removing an API path. E.g. &lt;code&gt;api.com/store/products&lt;/code&gt; is been removed;&lt;/li&gt;
&lt;li&gt;Removing a query param of a request. E.g. query parameter &lt;code&gt;?color=red&lt;/code&gt; is been removed;&lt;/li&gt;
&lt;li&gt;Renaming a query parameter. E.g. query parameter &lt;code&gt;?color=red&lt;/code&gt; now is &lt;code&gt;?product-color=red&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Renaming a body attribute on request or on response. E.g. &lt;code&gt;{ ..., "color": "red" }&lt;/code&gt; now is &lt;code&gt;{ ..., "product-color": "red" }&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Turning a parameter from optional to required, either path param, query param or the request body;&lt;/li&gt;
&lt;li&gt;Changing acceptable values for an enumerator param;&lt;/li&gt;
&lt;li&gt;Denying a content-type that was accepted earlier, either on response or request;&lt;/li&gt;
&lt;li&gt;Adding a required request header;&lt;/li&gt;
&lt;li&gt;Removing a response header;&lt;/li&gt;
&lt;li&gt;Removing a response body attribute;&lt;/li&gt;
&lt;li&gt;Changing a parameter or attribute type, either on the request or response;&lt;/li&gt;
&lt;li&gt;Increasing restrictions for as parameter, either a path, query string or body param. E.g not not accept attribute &lt;code&gt;name&lt;/code&gt; over 50 characters;&lt;/li&gt;
&lt;li&gt;Changing default value of an optional parameter. E.g. default value for &lt;code&gt;payment-method&lt;/code&gt; if it is not informed will be &lt;code&gt;credit&lt;/code&gt;, but it used to be &lt;code&gt;debit&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Adding a new Http Status Code response. E.g. when there aren't any products in the bag, &lt;code&gt;GET products&lt;/code&gt; used to return Http &lt;code&gt;200&lt;/code&gt; and an empty array, but now it gonna return &lt;code&gt;404&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;Removing a Http Status Code response. E.g. opposite of the above example.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Changes that may be handled on the current API version
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Adding a new resource;&lt;/li&gt;
&lt;li&gt;Adding a new supported method to an API resource;&lt;/li&gt;
&lt;li&gt;Adding a new resource path;&lt;/li&gt;
&lt;li&gt;Turning to optional a required parameter, either it is a path, query string or body attribute param;&lt;/li&gt;
&lt;li&gt;Adding new optional parameters;&lt;/li&gt;
&lt;li&gt;Adding new attributes to an API response.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>api</category>
      <category>restapi</category>
    </item>
    <item>
      <title>AWS API Gateway + Terraform + Serverless Framework - Part 1</title>
      <dc:creator>Vinícius A. dos Santos</dc:creator>
      <pubDate>Fri, 12 Feb 2021 12:44:27 +0000</pubDate>
      <link>https://dev.to/viniciusvasti/aws-api-gateway-terraform-serverless-framework-part-1-1772</link>
      <guid>https://dev.to/viniciusvasti/aws-api-gateway-terraform-serverless-framework-part-1-1772</guid>
      <description>&lt;p&gt;Hi, everyone!&lt;br&gt;
For this "Hands on!" we're going to build an REST API with &lt;strong&gt;AWS API Gateway&lt;/strong&gt;, provisioned with &lt;strong&gt;Terraform&lt;/strong&gt; and backed by &lt;strong&gt;AWS Lambda&lt;/strong&gt; built with &lt;strong&gt;Serverless Framework&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
The REST API will allow us to send SMS Messages using &lt;strong&gt;AWS SNS&lt;/strong&gt;. Sounds like a lot of things, but it's no that lot of working.&lt;br&gt;&lt;br&gt;
For this part 1, we'll provision our API Gateway with Terraform and for part 2 and 3:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://vinisantos.dev/posts/hands-on-aws-agw-terraform-sls-framework-part-2"&gt;Part 2: coding the backend with Serverless Framework&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://vinisantos.dev/posts/hands-on-aws-agw-terraform-sls-framework-part-3"&gt;Part 3: securing the API with Amazon Cognito&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  About the tech stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/"&gt;AWS&lt;/a&gt;: Most popular Cloud provider. You need an account to follow this article properly;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/api-gateway/"&gt;AWS API Gateway&lt;/a&gt;: AWS managed API Gateway that will expose our rest endpoints;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/lambda/"&gt;AWS Lambda&lt;/a&gt;: serverless functions on AWS working as our backend;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/sns/"&gt;AWS SNS&lt;/a&gt;: AWS Simple Notification Service that, among other types of notifications, allow us to send SMS for a phone number;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.terraform.io/"&gt;Terraform&lt;/a&gt;: IaC (Infrastructure as Code) tool that allow us to provision cloud resources supporting several cloud providers;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.serverless.com/"&gt;Serverless Framework&lt;/a&gt;: a Framework for support building and deploying serverless functions grouped as a Serverless Service, allowing also the provisioning of resources need for these functions;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/"&gt;NodeJS&lt;/a&gt;: JS runtime where our JavaScript lambda functions gonna be running;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript"&gt;JavaScript&lt;/a&gt;: Of course, the programing language we'll write our lambda.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  Why Terraform, since Serverless Framework itself can provision AWS resources?
&lt;/h3&gt;

&lt;p&gt;Well, it's very common to have an API Gateway serving different backend services.&lt;br&gt;&lt;br&gt;
Ex: endpoint X points to a serverless function, endpoint Y points to Java Spring Boot Microservice, endpoint Z points to third-party API.&lt;br&gt;&lt;br&gt;
If the API Gateway gets provisioned by the serverless Service, it's infrastructure code gonna be highly coupled to this service and you need to implement the other types of integrations using this service as a proxy (creating more lambdas and increasing the infrastructure cost and complexity).&lt;br&gt;&lt;br&gt;
Also, if you destroy this Service, the API Gateway gonna be destroyed too.&lt;/p&gt;

&lt;p&gt;So, hands on!&lt;/p&gt;
&lt;h3&gt;
  
  
  Terraform AWS API Gateway provisioning
&lt;/h3&gt;

&lt;p&gt;If haven't Terraform installed, do it: &lt;a href="https://www.terraform.io/downloads.html"&gt;https://www.terraform.io/downloads.html&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
When provisioning resources, the docs helps a lot: &lt;a href="https://www.terraform.io/docs/providers/aws/index.html"&gt;https://www.terraform.io/docs/providers/aws/index.html&lt;/a&gt;.&lt;br&gt;&lt;br&gt;
Nobody should try to memorize the code for the whole bunch of services AWS provides.&lt;/p&gt;

&lt;p&gt;First, we need set the cloud provider configurations.&lt;br&gt;&lt;br&gt;
Let's create file &lt;code&gt;provider.tf&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="n"&gt;provider&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;tf&lt;/span&gt;
&lt;span class="n"&gt;provider&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="n"&gt;aws&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;region&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="n"&gt;us&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;east&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;
    &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="err"&gt;“&lt;/span&gt;&lt;span class="mf"&gt;2.61&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt;
    &lt;span class="n"&gt;access_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"your-access-key”
    secret_key = "&lt;/span&gt;&lt;span class="n"&gt;your&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;secret&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="err"&gt;”&lt;/span&gt; 
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are telling terraform that our provider is AWS and we want provision resources on &lt;code&gt;us-east-1&lt;/code&gt; region.&lt;br&gt;
We're also setting aws credentials having the roles and policies needed to manage API Gateway (we could set the credentials as environment variables as well).&lt;br&gt;
I's important set the version of terraform aws plugin to avoid upgrades with breaking changes issues.&lt;br&gt;
Now, we can init terraform in this project running in terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;terraform init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should se the message &lt;code&gt;Terraform has been successfully initialized!&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
To finally provision an API Gateway, let's create another &lt;code&gt;.tf&lt;/code&gt; file as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;tf&lt;/span&gt;
&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s"&gt;"aws_api_gateway_rest_api"&lt;/span&gt; &lt;span class="s"&gt;"my_api_gateway"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"My API"&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"AWS Rest API example with Terraform"&lt;/span&gt;
  &lt;span class="n"&gt;endpoint_configuration&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;types&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"REGIONAL"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;resource&lt;/code&gt;: provision a cloud resource to be managed by Terraform;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aws_api_gateway_rest_api&lt;/code&gt;: the type of resource;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;my_api_gateway&lt;/code&gt;: a name to reference this resource in this project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The content inside the block refers to attributes of the API Gateway. You can look at AWS API Gateway if you are not familiar.&lt;/p&gt;

&lt;p&gt;We can now execute the command below to check what Terraform gonna do after we apply the provisioning plan:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;terraform plan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Among other output messages, you should see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Terraform&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;perform&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;following&lt;/span&gt; &lt;span class="nl"&gt;actions:&lt;/span&gt;
  &lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="n"&gt;aws_api_gateway_rest_api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;my_api_gateway&lt;/span&gt; &lt;span class="n"&gt;will&lt;/span&gt; &lt;span class="n"&gt;be&lt;/span&gt; &lt;span class="n"&gt;created&lt;/span&gt;
  &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s"&gt;"aws_api_gateway_rest_api"&lt;/span&gt; &lt;span class="s"&gt;"my_api_gateway"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;api_key_source&lt;/span&gt;           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"HEADER"&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;arn&lt;/span&gt;                      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;known&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;created_date&lt;/span&gt;             &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;known&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;              &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"AWS Rest API example with Terraform"&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;execution_arn&lt;/span&gt;            &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;known&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;                       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;known&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;minimum_compression_size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;                     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"My API"&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;root_resource_id&lt;/span&gt;         &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;known&lt;/span&gt; &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
      &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;endpoint_configuration&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
          &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;types&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;
              &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"REGIONAL"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
            &lt;span class="o"&gt;]&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="nl"&gt;Plan:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;change&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;destroy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see on the last line, Terraform gonna add 1 resource, change none and destroy none.&lt;br&gt;&lt;br&gt;
It's not guaranteed that this plan will be exactly the same applied. So we could use &lt;code&gt;$ terraform plan -out&lt;/code&gt;, but this plan is pretty simple.&lt;br&gt;&lt;br&gt;
To really apply the changes, the command is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;terraform apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then exactly plan to be executed will be presented again and you can answer &lt;code&gt;yes&lt;/code&gt;.&lt;br&gt;&lt;br&gt;
Going to AWS Console and looking for API Gateway Resource (region us-east-1), we can see the API created:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HSAFERA6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vinisantos.dev/images/posts/hands-on-aws-agw-terraform-sls-framework-part-1/aws_api_gateway.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HSAFERA6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vinisantos.dev/images/posts/hands-on-aws-agw-terraform-sls-framework-part-1/aws_api_gateway.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But clicking on it, there's no api resources paths:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cT8V5uzJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vinisantos.dev/images/posts/hands-on-aws-agw-terraform-sls-framework-part-1/aws_api_gateway_no_paths.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cT8V5uzJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vinisantos.dev/images/posts/hands-on-aws-agw-terraform-sls-framework-part-1/aws_api_gateway_no_paths.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's define that our API base path gonna be &lt;code&gt;&amp;lt;api-url&amp;gt;/my-api/v1&lt;/code&gt;.&lt;br&gt;
Back to Terraform files, we add this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;gateway&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;tf&lt;/span&gt;
&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s"&gt;"aws_api_gateway_rest_api"&lt;/span&gt; &lt;span class="s"&gt;"my_api_gateway"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s"&gt;"aws_api_gateway_resource"&lt;/span&gt; &lt;span class="s"&gt;"my_api"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;rest_api_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aws_api_gateway_rest_api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;my_api_gateway&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;
  &lt;span class="n"&gt;parent_id&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aws_api_gateway_rest_api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;my_api_gateway&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;root_resource_id&lt;/span&gt;
  &lt;span class="n"&gt;path_part&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"my-api"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;resource&lt;/span&gt; &lt;span class="s"&gt;"aws_api_gateway_resource"&lt;/span&gt; &lt;span class="s"&gt;"v1"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;rest_api_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aws_api_gateway_rest_api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;my_api_gateway&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;
  &lt;span class="n"&gt;parent_id&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;aws_api_gateway_resource&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;my_api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;
  &lt;span class="n"&gt;path_part&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"v1"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;aws_api_gateway_resource&lt;/code&gt;: the type of resource is api gateway resource;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rest_api_id&lt;/code&gt;: the id of the API Gateway that owns this resource;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;parent_id&lt;/code&gt;: the id of parent path, which is the root "/" of the API Gateway;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;path_part&lt;/code&gt;: the path part we want to create.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that for "v1" resource, the parent_id is the id of "my_api" resource, thus the complete path gonna be "/my-api/v1".&lt;br&gt;&lt;br&gt;
Running apply again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;terraform apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We should see on AWS Console three API resources ("/", "my-api" and "v1"):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H2wScLg5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vinisantos.dev/images/posts/hands-on-aws-agw-terraform-sls-framework-part-1/aws_api_gateway_with_paths.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H2wScLg5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://vinisantos.dev/images/posts/hands-on-aws-agw-terraform-sls-framework-part-1/aws_api_gateway_with_paths.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;






&lt;p&gt;That's it for this post. In part 2 we're going to implement backend with Serverless and part 3 we'll implement authentication with Amazon Cognito:&lt;/p&gt;

&lt;h3&gt;
  
  
  Related Posts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://vinisantos.dev/posts/hands-on-aws-agw-terraform-sls-framework-part-2"&gt;AWS API Gateway + Terraform + Serverless Framework - Part 2&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vinisantos.dev/posts/hands-on-aws-agw-terraform-sls-framework-part-3"&gt;AWS API Gateway + Terraform + Serverless Framework - Part 3&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>terraform</category>
      <category>awsapigateway</category>
      <category>aws</category>
      <category>serverless</category>
    </item>
  </channel>
</rss>
