Create a template sync configuration
Learn how to create a template sync configuration with AWS Proton.
Create a template sync configuration prerequisites:
-
A registered a repository with AWS Proton.
-
A template bundle is located in your repository.
The repository registration consists of the following:
-
An AWS CodeStar connections connection that gives AWS Proton permission to access your repository and subscribe to its notifications.
-
A service linked role. When you register your repository, the service linked role is created for you.
Before you create your first template sync configuration, push a template bundle to your repository as shown in the following directory layout.
/templates/ # subdirectory (optional) /templates/my-env-template/ # template name /templates/my-env-template/v1/ # template version /templates/my-env-template/v1/infrastructure/ # template bundle /templates/my-env-template/v1/schema/
After you create your first template sync configuration, new template versions are automatically created when you push a commit that adds an updated
template bundle under a new version (for example, under /my-env-template/v2/
).
/templates/ # subdirectory (optional) /templates/my-env-template/ # template name /templates/my-env-template/v1/ # template version /templates/my-env-template/v1/infrastructure/ # template bundle /templates/my-env-template/v1/schema/ /templates/my-env-template/v2/ /templates/my-env-template/v2/infrastructure/ /templates/my-env-template/v2/schema/
You can include new template bundle versions for one or more sync configured templates in a single commit. AWS Proton creates a new template version for each new template bundle version that was included in the commit.
After you created the template sync configuration, you can still manually create new versions of the template in the console or with the AWS CLI by uploading template bundles from an S3 bucket. Template syncing only works in one direction: from your repository to AWS Proton. Manually created template versions aren’t synced.
After you set up a template sync configuration, AWS Proton listens for changes to your repository. Whenever a change is pushed, it looks for any
directory that has the same name as your template. It then looks inside that directory for any directories that look like major versions. AWS Proton
registers the template bundle to the corresponding template major version. The new versions are always in the DRAFT
state. You can publish the new versions with the console or AWS CLI.
For example, suppose you have a template that's called my-env-template
configured to sync from my-repo/templates
on branch
main
with the following layout.
/code /code/service.go README.md /templates/ /templates/my-env-template/ /templates/my-env-template/v1/ /templates/my-env-template/v1/infrastructure/ /templates/my-env-template/v1/schema/ /templates/my-env-template/v2/ /templates/my-env-template/v2/infrastructure/ /templates/my-env-template/v2/schema/
AWS Proton syncs the contents of /templates/my-env-template/v1/
to my-env-template:1
and the contents of
/templates/my-env-template/v2/
to my-env-template:2
. If they don’t already exist, it creates these major versions.
AWS Proton found the first directory that matched the template name. You can limit the directories AWS Proton searches by specifying a
subdirectoryPath
when you create or edit a template sync configuration. For example, you can specify /production-templates/
for subdirectoryPath
.
You can create a template sync configuration using the console or CLI.
Syncing service templates
The preceding examples show how you can sync environment templates. Service templates are similar. However, they also require an additional file
that's called the .compatible-envs
file. This file contains a line-separated list of environment templates and major versions that are
compatible with the service template.
./templates/ # subdirectory (optional) /templates/my-svc-template/ # service template name /templates/my-svc-template/v1/ # service template version /templates/my-svc-template/v1/.compatible-envs # service template's compatible envs file /templates/my-svc-template/v1/infrastructure/ # template bundle /templates/my-svc-template/v1/schema/
The .compatible-envs
file contains the names and major versions of the environment templates that are compatible with this service
template.
my-env-template:1 my-env-template:2
This file indicates that the major version 1 of the my-svc-template
service template is compatible with major versions 1 and 2 of the
my-env-template
environment template.