Deployed Developer Stack Guide
Deployed Developer Stack Guide¶
Prerequisites¶
You should have the following from installing the prerequisites in the Developer Onboarding guide:
Additional Requirements:
Docker with Docker Compose (or Podman with Podman Compose)
Access to the following repositories:
Begin your deployment¶
This will deploy to AWS firefly-music-dev. Note: You need to perform these steps for both the metalfly_api and amu_webapi packages.
Install your requirements:
yarn install cd cdk yarn install
Note: It is important to consistently use
yarnand notnpmfor intalling dependencies unless otherwise noted. We deploy withyarnso any installations done withnpmare not guaranteed to be included in the deployment.Compile your code:
yarn buildTo deploy:
yarn dev-deploy:iad
Note: If you get errors, you may need to re-run the firefly script from the Developer Onboarding document.
Available Deployment Commands¶
yarn dev-deploy:iadfor us-east-1yarn dev-deploy:dubfor eu-west-1yarn dev-deploy:pdxfor us-west-2
Or
yarn dev-deploy:allfor all three regions
Post-Deployment¶
After deployment, you’ll see 3 CloudFormation stacks in the dev account:
MetalFly-API-<username>MetalFly-Core-<username>MusicFirefly-<username>
MetalFly API generates Global Accelerator endpoints in this format:
https://<SDE_ALIAS>.<AWS_REGION>.metal.beta.gql.music.amazon.dev
Example: https://ryanyhu.us-east-1.metal.beta.gql.music.amazon.dev/
Insomnia Setup¶
Please see the Insomnia setup guide to simplify LoginWithAmazon integration and test directly against your new API endpoint.
Running the tests¶
There are two types of test suites available: unit and integration tests.
Run the unit tests:
yarn test
Run the integration tests against your own deployed endpoints:
yarn testIntegration
You can also run the integration tests against your own endpoints as deployed in
the previous section. In order to do so you need to create the file
endpoint.env in the root directory with this content:
NA_ENDPOINT=https://REPLACE-WITH-YOUR-NA-ENDPOINT.execute-api.us-east-1.amazonaws.com/dev/
EU_ENDPOINT=https://REPLACE-WITH-YOUR-EU-ENDPOINT.execute-api.eu-west-1.amazonaws.com/dev/
FE_ENDPOINT=https://REPLACE-WITH-YOUR-FE-ENDPOINT.execute-api.us-west-2.amazonaws.com/dev/
Populate the file with your own endpoint values as obtained when deploying your stack to NA, EU and FE geographic regions. After you create this file, the integration tests will use your endpoints.
Note: If you are testing a new client integration, have the Devex API Team on-call add your Lambda role to the AAA page for MusicFireFlyService. This allows your developer stack to retrieve the token from the client. If this is not done, the token will return null.
Test client service package changes with amu_webapi¶
Since the amu_webapi package is a separate project from client service packages, local changes to the client need to be connected to amu_webapi.
yarn packis recommended.yarn packis required if you want to test against your devstack using Insomnia, so your changes get deployed.
Yarn pack instructions¶
Yarn Pack will build the client package and contain it in a compressed file which can be referenced by another project.
This will allow amu_webapi dev deployment to include the local client changes.
Step 1: Pack¶
Make sure to install and build before you pack:
yarn install --force && yarn build
Navigate to the root of your local client package and run:
yarn pack
If it ran successfully, you should be able to see a new .tgz file in the project folder.
You should be able to see the newly created file by running git status in the client package.
your-client-package-v1.0.0.tgz
Run this step before each dev deployment.
Note: If the deployment is not reflecting the changes, you may need to bump the version number of the client package. Make this change in the package.json in the client package under version.
Step 2: Point amu_webapi to the packed file¶
Edit package.json of the amu_webapi project.
Add this line, replacing the version.
"dependencies": {
...
your-client-package: "file:RELATIVE_PATH_TO_CLIENT_PACKAGE/your-client-package-v1.0.0.tgz",
...
}
The packed file is now linked and you should be able to deploy to your local dev. You only have to perform this step once.
Note: When you are ready to commit your changes, return this dependency to the original state.
"dependencies": {
...
your-client-package: "^1.0.0",
...
}
Note:
If you encounter an error when running
yarn install, you may have a space afterfile:that needs to be removed.You also might need to run
yarn cache clean, or increment the dependency’s version number, to get the yarn cache to recognize newly-built changes in the.tgzfile.
Yarn link for local testing¶
If you are testing locally against your unit test, yarn link can be used.
Yarn link will symlink a local package (client service package) to an existing project (amu_webapi).
The client service package will be directly linked to the node_modules of the amu_webapi project.
Changes in the client service package will reflect immediately in the node_modules of the project that is using it. It will enable your IDE (such as VSCode) to autofill with the most recent local changes.
Step 1: Yarn link in client service package¶
Navigate to the root of your local client service package. Link the client service package to yarn.
yarn link
The output should look like the following:
yarn link v1.22.10
success Registered "your-client-package".
info You can now run `yarn link "your-client-package"` in the projects where you want to use this package and it will be used instead.
Step 2: Yarn link in amu_webapi¶
Navigate to the root of the local amu_webapi package.
yarn link "your-client-package"
If everything is working, the output should resemble:
yarn link v1.22.10
success Using linked package for "your-client-package".
Navigate to the root of the local amu_webapi package and recompile all packages.
yarn install --force
You only need to perform this once unless the package is cloned again to another folder. In that case you will need to reset.
Reset instructions¶
Navigate to the root of your local client service package.
yarn unlink
You should see this output
yarn unlink v1.22.10
success Unregistered "your-client-package".
info You can now run `yarn unlink "your-client-package"` in the projects where you no longer want to use this package.
Navigate to the root of the local amu_webapi package.
yarn unlink "your-client-package"
If everything worked, you should see this output
yarn unlink v1.22.10
success Removed linked package "your-client-package".
info You will need to run `yarn install --force` to re-install the package that was linked.
Recompile all packages.
yarn install --force
Making changes on FireFly¶
Flow overview:
Create a local branch with your changes
git checkout -b my-new-branch
Note: Make sure you are not tracking origin/main with this new branch.
Make your changes and stage them
git add .
Add a commit using commitzen and follow the prompts
git cz
Publish your changes to your remote branch. Gitlab will provide you with a link to create a merge request
git push origin my-new-branch
For more details on how to Contribute to the firefly codebase and our process, see the Firefly contribution guidelines.
To learn more about Gitlab merge requests, see Creating merge requests.
FAQ¶
After I deploy FireFly against a dev stack, where should I check the logs?
You will find a log group for your username in your firefly-dev account.
Do I need to deploy MetalFly API for every amu_webapi change?
For submitting MRs to amu_webapi, you need to deploy your MetalFly API cluster to each region ONCE, otherwise MR will fail with deploy:Core:dev [region] error. See the Troubleshooting Guide for details.
If your MetalFly API cluster is already deployed, you do not need to deploy it again.
