# Example: Deploy a microservice to an existing shared application The following example creates a new AWS Migration Hub Refactor Spaces service based on an AWS Lambda function and a route for `GET` and `POST` methods to the path `/unicorns/reviews`, in an existing AWS Migration Hub Refactor Spaces application deployed in or shared with the executing AWS account. The use case for this example is to deploy the environment and application in separate CI/CD pipelines and deploy the service as part of the microservice CI/CD pipeline in a separate account. This example sets up the following: * An AWS Migration Hub Refactor Spaces service (Unistore-AddReview) pointing at a microservice deployed as an AWS Lambda function with the ARN `arn:aws:lambda:us-east-1:999999999999:function:AddReview`. This service is in an existing AWS Migration Hub Refactor Spaces application shared with the account with the ID `app-xy1ABCDE1a`, in the environment `env-ab9ZXYVT9z`. * A route that sends `POST` and `GET` requests to `/unicorns/reviews` to the Lambda function. ## Requirements | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.3.0 | | [awscc](#requirement\_awscc) | >= 0.49.0 | ## Providers No providers. ## Modules | Name | Source | Version | |------|--------|---------| | [refactor\_spaces\_microservice\_x](#module\_refactor\_spaces\_microservice\_x) | aws-ia/refactorspaces/awscc | 0.0.2 | ## Resources No resources. ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| | [application\_id](#input\_application\_id) | AWS Migration Hub Refactor Spaces application ID of deployed application to configure the new microservice. | `string` | `"app-xy1ABCDE1a"` | no | | [application\_name](#input\_application\_name) | Display name of existing AWS Migration Hub Refactor Spaces application to add the microservice. | `string` | `"Unistore"` | no | | [description\_lambda\_microservice](#input\_description\_lambda\_microservice) | Description for Lambda-based microservice to add to existing AWS Migration Hub Refactor Spaces application. | `string` | `"The new AddToCart Microservice"` | no | | [display\_name\_lambda\_microservice](#input\_display\_name\_lambda\_microservice) | Display name for new Lambda-based microservice to add to existing AWS Migration Hub Refactor Spaces application, to strangle a function of the monolith. | `string` | `"Unistore-AddReview"` | no | | [environment\_id](#input\_environment\_id) | AWS Migration Hub Refactor Spaces environment ID of an already-deployed environment to deploy the new microservice. | `string` | `"env-ab9ZXYVT9z"` | no | | [http\_verbs\_lambda\_microservice](#input\_http\_verbs\_lambda\_microservice) | List of HTTP methods AWS Migration Hub Refactor Spaces uses to match traffic destined for new microservice. | `list(string)` |
[| no | | [lambda\_arn\_microservice](#input\_lambda\_arn\_microservice) | ARN of Lambda function to use as AWS Migration Hub Refactor Spaces service to strangle a function of the monolith. | `string` | `"arn:aws:lambda:us-east-1:999999999999:function:AddReview"` | no | | [source\_path\_lambda\_microservice](#input\_source\_path\_lambda\_microservice) | Path AWS Migration Hub Refactor Spaces uses to match traffic destined for new microservice. Paths must start with / and are relative to the base of the application. | `string` | `"/unicorns/reviews"` | no | ## Outputs | Name | Description | |------|-------------| | [applications](#output\_applications) | Collection of AWS Migration Hub Refactor Spaces application managed by or used.
"POST",
"GET"
]
applications = [| | [environment](#output\_environment) | AWS Migration Hub Refactor Spaces environment resource attributes. Full output of [`awscc_refactorspaces_environment`](https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/refactorspaces_environment). | | [services](#output\_services) | Collection of AWS Migration Hub Refactor Spaces services and associated routes.
{
api_gateway_id = "a0abcdefg1o1"
nlb_arn = "arn:aws:elasticloadbalancing:us-east-1:99999999999:loadbalancer/net/refactor-spaces-nlb-XXXX/YYYY",
vpc_link_id = "00abcde"
application = {
"application_identifier" = "app-BSXbxAPn1r",
"arn" = "arn:aws:refactor-spaces:us-east-1:99999999999:environment/env-ZoiD5hlRyz/application/app-BSXbxAPn1r",
"environment_identifier" = "env-ZoiD5hlRyz",
...
}
application_proxy_vpc_attributes = {
}
}
]
services = [|
{
"arn" = "arn:aws:refactor-spaces:us-east-1:99999999999:environment/env-ABC/application/app-XYZ/service/svc-XYZ"
"name" = "legacy",
description = "Legacy monolithic application entry point."
routes = [
{
"arn" = "arn:aws:refactor-spaces:us-east-1:99999999999:environment/env-ABC/application/app-XYZ/route/rte-ABCD"
"route_identifier" = "rte-ABCD"
"route_type": "DEFAULT"
...
}
]
...
}
]