Skip to content

Commit fad7171

Browse files
sobermaws-amplify-opstttolaws-amplify-botHuiSF
authored
chore: Update amplify-js API references (#8624)
* chore: amplify-js api references update (#8299) * chore(function): fix code snippet at set-up-function page (#8046) * Add `.authorization(allow => [allow.guest()])` * chore: Update amplify-js API references --------- Co-authored-by: Takahashi <tttol.t4k.b1z@gmail.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: amplify-js api references update (#8316) * chore: add decode cookie value strings note to SSR example (#8300) * chore: fix broken maplibre links (#8301) * chore: update secrets path ref (#8298) * chore: add callout about committing amplify config files for expo eas build (#8274) * chore: add callout about committing amplify config files for expo eas build * chore: expand the callout for not push amplify_outputs to remote repo * chore(deps): bump actions/upload-artifact from 4.6.0 to 4.6.2 (#8307) Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 4.6.0 to 4.6.2. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@65c4c4a...ea165f8) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump actions/setup-node from 4.2.0 to 4.3.0 (#8306) Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4.2.0 to 4.3.0. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](actions/setup-node@1d0ff46...cdca736) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat: add retry strategy for api-rest category (#8295) * fix: Remove reference to using default with enum (#8311) * fix(storage): update instructions for adding external S3 buckets to Amplify (#8289) * fix(storage): update instructions for adding/integrating with external S3 buckets * rewrite examples, add user identity ID config, add examples for configuring storage without Amplify backend * address feedback, align some wording * reorder guest and auth'd user examples, update backend code examples to use CDK bucket construct * address feedback * update callout for adding existing bucket and amplify storage together, revert callout on owners example section * adjust headings, add heading before examples for better linking * chore: bump next version (#8313) * chore(deps): bump aws-actions/configure-aws-credentials (#8276) Bumps [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) from 4.0.3 to 4.1.0. - [Release notes](https://github.com/aws-actions/configure-aws-credentials/releases) - [Changelog](https://github.com/aws-actions/configure-aws-credentials/blob/main/CHANGELOG.md) - [Commits](aws-actions/configure-aws-credentials@4fc4975...ececac1) --- updated-dependencies: - dependency-name: aws-actions/configure-aws-credentials dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump aws-actions/aws-secretsmanager-get-secrets (#8278) Bumps [aws-actions/aws-secretsmanager-get-secrets](https://github.com/aws-actions/aws-secretsmanager-get-secrets) from 2.0.7 to 2.0.8. - [Release notes](https://github.com/aws-actions/aws-secretsmanager-get-secrets/releases) - [Commits](aws-actions/aws-secretsmanager-get-secrets@1d6311a...fbd65ea) --- updated-dependencies: - dependency-name: aws-actions/aws-secretsmanager-get-secrets dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: update custom message with admincreateuser specifics (#8314) * chore: Update amplify-js API references * commit to trigger workflow * add pre-prod/main to workflows --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Hui Zhao <10602282+HuiSF@users.noreply.github.com> Co-authored-by: Tiffany Yeung <tnwyeung@amazon.com> Co-authored-by: Jay Raval <jay.ambrish.raval@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: aadimch <aadimch@amazon.com> Co-authored-by: Aaron S. <94858815+stocaaro@users.noreply.github.com> Co-authored-by: James Jarvis <jjarvisp@amazon.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: ashika112 <akasivis@amazon.com> * chore: Update amplify-js API references (#8340) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8355) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8366) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8378) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8394) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8408) * fix: resolve merge from main missing deleted file (#8410) * chore: Update amplify-js API references (#8431) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8441) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8466) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: amplify-js api references update (#8494) * chore: Update amplify-js API references * fix: update test mocks to include required PageNode properties --------- Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: osama-rizk <osos2026@gmail.com> * chore: amplify-js api references update (#8499) * chore: Update amplify-js API references (#8523) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8614) Co-authored-by: aws-amplify-bot <aws@amazon.com> * chore: Update amplify-js API references (#8623) Co-authored-by: aws-amplify-bot <aws@amazon.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: aws-amplify-ops <48034866+aws-amplify-ops@users.noreply.github.com> Co-authored-by: Takahashi <tttol.t4k.b1z@gmail.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: Hui Zhao <10602282+HuiSF@users.noreply.github.com> Co-authored-by: Tiffany Yeung <tnwyeung@amazon.com> Co-authored-by: Jay Raval <jay.ambrish.raval@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: aadimch <aadimch@amazon.com> Co-authored-by: Aaron S. <94858815+stocaaro@users.noreply.github.com> Co-authored-by: James Jarvis <jjarvisp@amazon.com> Co-authored-by: ashika112 <akasivis@amazon.com> Co-authored-by: Simone319 <zimzha@amazon.com> Co-authored-by: osama-rizk <osos2026@gmail.com>
1 parent aec960c commit fad7171

11 files changed

Lines changed: 13095 additions & 5727 deletions

File tree

‎src/directory/apiReferences/amplify-js.json‎

Lines changed: 11878 additions & 5727 deletions
Large diffs are not rendered by default.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';
2+
3+
export const meta = {
4+
title: 'Fullstack branch deployments',
5+
description: 'Use fullstack branch deployments to test changes from feature branches.',
6+
platforms: [
7+
'android',
8+
'angular',
9+
'flutter',
10+
'javascript',
11+
'nextjs',
12+
'react',
13+
'react-native',
14+
'swift',
15+
'vue'
16+
]
17+
};
18+
19+
export const getStaticPaths = async () => {
20+
return getCustomStaticPath(meta.platforms);
21+
};
22+
23+
export function getStaticProps(context) {
24+
return {
25+
props: {
26+
meta
27+
}
28+
};
29+
30+
}
31+
32+
Amplify code-first DX (Gen 2) offers fullstack branch deployments that allow you to automatically deploy infrastructure and application code changes from feature branches. This enables testing changes in an isolated environment before merging to the main branch.
33+
34+
## Set up feature branch deployments
35+
36+
After you've deployed your [first branch](/[platform]/start/quickstart/), you can manually connect more, but the recommended workflow is to use the **branch auto-detection** feature.
37+
38+
1. Log in to the [Amplify console](https://console.aws.amazon.com/amplify/home) and choose your app.
39+
40+
2. Navigate to **App settings > Branch settings**, select **Edit** and enable **Branch auto-detection** and **Branch auto-disconnection**. The following video uses the default settings, which will connect any branch in your repo automatically. Branch auto-disconnection will ensure that if you delete a branch from your repository, the branch will also be deleted.
41+
42+
<Callout>
43+
You can also define a pattern to connect only certain branches. For example, setting `dev`, `staging`, and `feature/*` will automatically connect all three branch types. Your `dev` and `staging` branches, as well as any branch that begins with `feature/`, will be connected.
44+
</Callout>
45+
46+
<Video src="/images/gen2/fullstack-branching/Enable-branch-autodetection.mp4" description="Video - Enable branch autodetection" />
47+
48+
3. Push a commit to your `feature/A` and `staging` branches that match the pattern. You should start seeing deployments on the console page. You will now have three fullstack branches deployed.
49+
50+
![Production, feature/A, and staging branches listed on app overview page in Amplify console.](/images/gen2/fullstack-branching/branches.png)
51+
52+
## Promote changes to production
53+
54+
In Gen 2, promoting changes to production follows the normal Git-based workflow.
55+
56+
![Workflow for merging changes from feature/A branch to main, or production, branch.](/images/gen2/fullstack-branching/gitflow.png)
57+
58+
1. Make a change in your `feature/A` branch.
59+
60+
```bash title="Terminal" showLineNumbers={false}
61+
git checkout -b feature/A
62+
63+
## make some edits to your code
64+
65+
git commit --am "New data model to track comments for todos added"
66+
67+
git push origin feature/A
68+
```
69+
70+
2. Submit a pull request to your `main` branch. Once your team has validated the changes, merge the pull request to `main`. This will initiate a build on your `main` branch and update any frontend or backend resources that you changed.
71+
72+
73+
### Generate client config
74+
75+
You can generate the config for a branch environment by running:
76+
77+
<InlineFilter filters={['angular','javascript','nextjs','react','react-native','swift','vue']}>
78+
For Web and React Native, generating the config with the default format and output directory.
79+
80+
```bash title="Terminal" showLineNumbers={false}
81+
npx ampx generate outputs --app-id <your-amplify-app-id> --branch <your-git-branch-name> --out-dir <path/to/config>
82+
```
83+
</InlineFilter>
84+
85+
<InlineFilter filters={['android']}>
86+
<Callout warning>
87+
Be sure to add a "raw" folder under app/src/main/res directory if it doesn't
88+
exist.
89+
</Callout>
90+
91+
```bash title="Terminal" showLineNumbers={false}
92+
npx ampx generate outputs --app-id <your-amplify-app-id> --branch <your-git-branch-name> --out-dir app/src/main/res/raw
93+
```
94+
</InlineFilter>
95+
<InlineFilter filters={['flutter']}>
96+
```bash title="Terminal" showLineNumbers={false}
97+
npx ampx generate outputs --app-id <your-amplify-app-id> --branch <your-git-branch-name> --format dart --out-dir lib
98+
```
99+
</InlineFilter>
100+
<InlineFilter filters={['swift']}>
101+
```bash title="Terminal" showLineNumbers={false}
102+
npx ampx generate outputs --app-id <your-amplify-app-id> --branch <your-git-branch-name>
103+
```
104+
105+
Once the sandbox environment is running, you would also generate the configuration file for your application. However, Xcode won't recognize the file by default. To recognize the files, you need to drag and drop the generated configuration file to your project.
106+
107+
<Video src="/images/gen2/getting-started/ios/ios-getting-started-2.mp4" description="Video - iOS Getting Started" />
108+
109+
</InlineFilter>
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
import { getCustomStaticPath } from '@/utils/getCustomStaticPath';
2+
3+
export const meta = {
4+
title: 'Cross-account deployments',
5+
description:
6+
'Set up a cross-account deployment pipeline powered by Amazon CodeCatalyst and AWS Amplify Hosting.',
7+
platforms: [
8+
'android',
9+
'angular',
10+
'flutter',
11+
'javascript',
12+
'nextjs',
13+
'react',
14+
'react-native',
15+
'swift',
16+
'vue'
17+
]
18+
};
19+
20+
export const getStaticPaths = async () => {
21+
return getCustomStaticPath(meta.platforms);
22+
};
23+
24+
export function getStaticProps(context) {
25+
return {
26+
props: {
27+
platform: context.params.platform,
28+
meta
29+
}
30+
};
31+
}
32+
33+
This guide walks you through how to create a trunk-based, multi-region deployment pipeline for applications built using AWS Amplify Gen 2. We will be using Amazon CodeCatalyst and AWS Amplify Hosting in this guide, but you can choose any CI/CD provider.
34+
35+
<Callout info>
36+
37+
**Note**: You can deploy this custom pipeline either in the us-west-2 or eu-west-1 Regions, as Amazon CodeCatalyst is currently only available in those two [AWS Regions](https://docs.aws.amazon.com/general/latest/gr/codecatalyst.html).
38+
39+
</Callout>
40+
41+
## Step 1: Set up an Amazon CodeCatalyst space
42+
43+
Please refer to this Amazon CodeCatalyst [guide](https://docs.aws.amazon.com/codecatalyst/latest/userguide/setting-up-topnode.html) for a detailed step-by-step walkthrough to set up your [space](https://docs.aws.amazon.com/codecatalyst/latest/userguide/spaces.html).
44+
45+
## Step 2: Deploy a fullstack Amplify Gen 2 app
46+
47+
<InlineFilter filters={["nextjs"]}>
48+
49+
- Use our [**Next.js starter template**](/[platform]/start/quickstart/nextjs-pages-router/#1-create-the-repository) to create a repository in your GitHub account.
50+
- Sign in to the [AWS Management Console](https://console.aws.amazon.com/).
51+
- Navigate to the Amplify console and select [**Create new app**](https://us-west-2.console.aws.amazon.com/amplify/create).
52+
- Select the **next-pages-template** repository, then select **Next**.
53+
- Review the details on the **Create Git Repository** page, then select **Save and deploy**.
54+
- Done! You have successfully deployed a fullstack Gen 2 app. You can review the status of the app deployment in the Amplify console.
55+
56+
</InlineFilter>
57+
58+
<InlineFilter filters={["angular", "android", "javascript", "react", "react-native", "swift", "vue", "flutter"]}>
59+
60+
- Sign in to the [AWS Management Console](https://console.aws.amazon.com/).
61+
- Navigate to the Amplify console and select [**Create new app**](https://us-west-2.console.aws.amazon.com/amplify/create).
62+
- Select the **next-pages-template** repository, then select **Next**.
63+
- Review the details on the **Create Git Repository** page, then select **Save and deploy**.
64+
- Done! You have successfully deployed a fullstack Gen 2 app. You can review the status of the app deployment in the Amplify console.
65+
66+
</InlineFilter>
67+
68+
69+
![Screenshot of completed deployment in AWS Amplify Gen 2 console](images/gen2/cross-account-deployments/pipeline1.png)
70+
71+
## Step 3: Update build specification
72+
73+
Add the `npx ampx generate outputs --branch $AWS_BRANCH --app-id $AWS_APP_ID` command to the build spec and comment out the `npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID` command. `ampx pipeline-deploy` runs a script to deploy backend updates, while `ampx generate outputs` fetches the latest `amplify_outputs.json` for the specified environment.
74+
75+
![Screenshot of Build image settings section in AWS Amplify Gen 2 console, with details about the app build specification](images/gen2/cross-account-deployments/pipeline10.png)
76+
77+
## Step 4: Disable automatic builds on the branch
78+
79+
You can configure Amplify to disable automatic builds on every code commit. Navigate to the app in the Amplify console. Under **App settings**, select **Branch settings**. From the **Branches** section, select the branch and then choose **Disable auto build** from the **Actions** dropdown menu.
80+
81+
<Video src="/images/gen2/fullstack-branching/auto-build.mp4" description="Video - Disable automatic builds on the branch" />
82+
83+
## Step 5: Create an incoming webhook
84+
85+
You can set up an incoming webhook to trigger a build without committing code to your Git repository. Use the Amplify Console to create an [incoming webhook](https://docs.aws.amazon.com/amplify/latest/userguide/webhooks.html).
86+
87+
Navigate to the app, under **Hosting > Build settings** select **Create webhook**. Provide a **name** for the webhook and select the **target branch** to build on incoming webhook requests.
88+
89+
![Screenshot of the Build settings page in the Amplify console showing the incoming webhooks feature](/images/gen2/fullstack-branching/multirepo5.png)
90+
91+
Next, select the webhook and copy the `curl` command which will be used to trigger a build for the app.
92+
93+
![Screenshot of the Incoming webhooks page in the Amplify console displaying the newly created webhook](/images/gen2/fullstack-branching/multirepo6.png)
94+
95+
## Step 6: Create a new Amazon CodeCatalyst project
96+
97+
Please refer to this Amazon CodeCatalyst [guide](https://docs.aws.amazon.com/codecatalyst/latest/userguide/projects-create.html#projects-create-github) for a detailed step-by-step walkthrough to create a new [project](https://docs.aws.amazon.com/codecatalyst/latest/userguide/projects.html).
98+
99+
<Callout info>
100+
101+
**Note**: When creating your project, select the **next-pages-template** GitHub repository, which we used to deploy the app in Step 2.
102+
103+
</Callout>
104+
105+
![Screenshot of CodeCatalyst console showing Source repositories section](images/gen2/cross-account-deployments/pipeline2.png)
106+
107+
## Step 7: Set up the resources in a different or target AWS account
108+
109+
To achieve a cross-account deployment, you will need to implement Steps 1 through 6 outlined previously in this guide in a different AWS account (for example, `production` account).
110+
111+
## Step 8: Add the target AWS account to the CodeCatalyst space
112+
113+
Navigate to the CodeCatalyst space created as part of Step 1, select **Settings**, and then select **AWS accounts**. Add the target **AWS account ID** (Step 7) to it and select **Associate AWS account**.
114+
115+
![Screenshot of CodeCatalyst console showing details of the Associate AWS account section](images/gen2/cross-account-deployments/pipeline12.png)
116+
117+
You will also need to create an IAM role in the target AWS account which will be assumed by the `staging` environment to perform actions and deploy resources in the `production` environment. As a best practice, we recommend attaching the [`AmplifyBackendDeployFullAccess`](https://docs.aws.amazon.com/amplify/latest/userguide/security-iam-awsmanpol.html#security-iam-awsmanpol-AmplifyBackendDeployFullAccess) AWS managed policy to the IAM role as it contains all the required permissions to deploy Gen 2 resources in your account. You can learn more about adding IAM roles to account connections in the CodeCatalyst [documentation](https://docs.aws.amazon.com/codecatalyst/latest/userguide/ipa-connect-account-addroles.html).
118+
119+
## Step 9: Create a workflow in the Amazon CodeCatalyst project
120+
121+
A workflow is an automated procedure that describes how to build, test, and deploy your code as part of a continuous integration and continuous delivery (CI/CD) system. You can learn more about workflows in the [Amazon CodeCatalyst User Guide](https://docs.aws.amazon.com/codecatalyst/latest/userguide/flows.html).
122+
123+
- Within the CodeCatalyst project, navigate to the **CI/CD** feature and select **Workflows**.
124+
- Select **Create workflow**.
125+
- Choose the **next-pages-template** GitHub repository and the branch **main** from the dropdown menu.
126+
- Next, select **Create**.
127+
128+
![Screenshot of the CodeCatalyst console showing details of the Create workflow dialog box](images/gen2/cross-account-deployments/pipeline3.png)
129+
130+
Once you create the workflow, you should see a **yaml** editor in the CodeCatalyst console.
131+
132+
![Screenshot of yaml editor in CodeCatalyst console](images/gen2/cross-account-deployments/pipeline4.png)
133+
134+
Switch the experience in the console to the **Visual** editor. Select the **Actions** button to see a list of workflow actions that you can add to your workflow.
135+
136+
![Screenshot of CodeCatalyst console showing the Workflows section with +Actions highlighted](images/gen2/cross-account-deployments/pipeline5.png)
137+
138+
Add the **Build** action to the workflow and select the **Add variable** button in the **Inputs** section. Add the following environment variables to it:
139+
140+
- AWS_APP_ID_STAGING: `amplify app id for staging app`
141+
- AWS_APP_ID_PRODUCTION: `amplify app id for production app`
142+
- AWS_BRANCH: `git branch name`
143+
144+
![Screenshot of CodeCatalyst console showing the Workflows section, focusing on Inputs for the build](images/gen2/cross-account-deployments/pipeline13.png)
145+
146+
Add another **Build** action to the workflow and select the **Depends on** button in the **Inputs** section. From the dropdown menu, select the name of the previous build action to set up the pipeline.
147+
148+
![Screenshot of CodeCatalyst console showing the Workflows section, focusing on the visual workflow and the Inputs section](images/gen2/cross-account-deployments/pipeline14.png)
149+
150+
Next, select the **Configuration** section and add the following information to each of the build actions:
151+
152+
- Environment information (optional): `staging, production, etc.`
153+
- AWS account connection: `your account connection`
154+
- Role: `role setup with your account connection`
155+
156+
![Screenshot of CodeCatalyst console showing the Workflows section, focusing on the Configuration section](images/gen2/cross-account-deployments/pipeline8.png)
157+
158+
You will then need to add the following shell commands to each of the build actions:
159+
160+
```bash title="Terminal" showLineNumbers={false}
161+
// This environment variable is required to run the pipeline-deploy command in a non Amplify CI environment
162+
- Run: export CI=1
163+
164+
// Perform a clean install of the dependencies
165+
- Run: npm ci
166+
167+
// Deploy the backend for your Amplify Gen 2 app
168+
- Run: npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
169+
170+
// Trigger frontend build using incoming webhooks
171+
- Run: if [ $AWS_BRANCH = "main" ]; then curl -X POST -d {} "`webhookUrl`&operation=startbuild" -H "Content-Type:application/json"; fi
172+
```
173+
174+
You can now run **Validate** to ensure your workflow definition `yaml` file is valid. Lastly, select **Commit** to save your changes.
175+
176+
<Callout info>
177+
178+
**Note**: Since workflows are saved as commits, and this workflow has a code push trigger enabled, committing the workflow will automatically start a new workflow run.
179+
180+
</Callout>
181+
182+
Next, you can review the result of the workflow run from the **Runs** tab:
183+
184+
![Screenshot of CodeCatalyst console showing the Workflows section, focusing on the Runs tab](images/gen2/cross-account-deployments/pipeline11.png)
185+
186+
Done! You have successfully set up a custom cross-account pipeline to deploy your frontend and backend for apps built using Amplify Gen 2. To summarize, this custom pipeline will enable you to deploy your backend initially with your `staging` environment using `ampx pipeline-deploy` in the CodeCatalyst workflow and `ampx generate outputs` will generate the `amplify_outputs.json` file for the `main` branch. Amplify Hosting will not deploy backend resources as part of the build and instead will use the deployed backend resources from the `main` branch. Once the staging environment deploys successfully, a similar process will be followed to deploy your `production` environment in a different AWS account.

0 commit comments

Comments
 (0)