commercetools Local Development Setup
Author:
Fluent Commerce
Changed on:
31 Jan 2024
Key Points
- Local development uses localstack to emulate AWS services
- AWS CLI Configuration is optional
- IntelliJ and Eclipse / STS Setup in local environment
Steps
Localstack
Local development uses localstack to emulate AWS services. Simply run the command below to have the image downloaded and the container running. Note that the container is set to always run unless stopped. Be aware that secrets and messages are not persisted between server restarts.
1docker-compose -f docker-compose.yml up -d localstack
Language: json
Name: Localstack
Description:
[Warning: empty required content area]AWS CLI Configuration (Optional)
This is only required if one wants to send events to the queues in localstack or manage secrets through the AWS CLI outside the localstack container. Run the AWS configuration and set your profile. The access key values can be anything but the region has to be us-east-1
1aws configure --profile localstack
2export AWS_PROFILE=localstack
Language: json
Name: command line
Description:
[Warning: empty required content area]IntelliJ Setup
Create a run configuration setting the spring profiles, environment variables and selecting the correct pre-configured localstack AWS profile. The application runs exactly the same way as it would in production and this is achieved by the properties below.
- Active Profiles: connector,dev-aws
- profile is always required, and it should be followed by the environment the application is running on (dev, test, qa or production).
`connector`
- is a handy profile for local development with AWS. It enables to the SDK to auto start the queue and use some pre-configured values for development.
`dev-aws`
- Environment Variables: SQS_BATCH=batch;SQS_EVENTS=events;SQS_CONNECTOR=commercetools_events
- These variables give actual names to the queues as these may vary per environment.
- AWS credential profile/region: Select the localstack profile and set the region to US-EAST-1.
- Ensures the region matches with localstack and allows spring to do the correct wiring of the AWS libraries.
For IntelliJ community version, pass the spring profile configuration as JVM parameters:
1--spring.profiles.active=connector,dev-aws
Language: json
Name: Profile
Description:
[Warning: empty required content area]Eclipse / STS Setup
Create a run configuration and set the spring profiles.