Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(amplify): Add resource support (wip) #3209

Closed
wants to merge 65 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
fca16f4
start of amplify
sthulb Jul 4, 2019
4604403
Adds docstrings
sthulb Jul 5, 2019
f5dac6f
adds default role
sthulb Jul 5, 2019
c7bc778
remvoes unused ref
sthulb Jul 5, 2019
e2244bb
add tests
sthulb Jul 5, 2019
8106650
fix resource name
sthulb Jul 5, 2019
a519b63
basic domain resource
sthulb Jul 8, 2019
d87f93c
package json fixes
sthulb Jul 8, 2019
7a8958d
adds basic tests
sthulb Jul 8, 2019
2a2fc85
domain tests
sthulb Jul 9, 2019
b8939d0
adds test to verify addsubdomain
sthulb Jul 9, 2019
bac81b0
moved EnvVars and BasicAuth to shared file
sthulb Jul 9, 2019
7d9e241
improves domain interface
sthulb Jul 9, 2019
f91ba93
adds exclude for from-method rule
sthulb Jul 9, 2019
df7587b
adds basic resolvers
sthulb Jul 9, 2019
d3a001f
Start of branch resource
sthulb Jul 9, 2019
d004a4a
adds shared and branch resources
sthulb Jul 9, 2019
8455f35
changes name of resource
sthulb Jul 10, 2019
01b46e6
changes the name of the resource
sthulb Jul 10, 2019
5d573ed
adds more tests to ensure stability
sthulb Jul 10, 2019
42ddf95
adds a new method to bulk add env vars
sthulb Jul 10, 2019
f2a232d
removes junk import
sthulb Jul 10, 2019
b9a038f
adds import of values in props
sthulb Jul 10, 2019
e8031ed
uses new resolvers
sthulb Jul 10, 2019
693ec41
add doc strings
sthulb Jul 10, 2019
4db73bf
adds doc string
sthulb Jul 10, 2019
bdbbac4
update deps
sthulb Jul 10, 2019
6b69aba
adds package-lock back
sthulb Jul 10, 2019
8f07595
renames service role
sthulb Jul 10, 2019
a239a8f
updates doc strings to match CFN docs
sthulb Jul 10, 2019
d804ae9
update physicalName
sthulb Jul 10, 2019
ad1d730
update tags default
sthulb Jul 10, 2019
5995e0b
changes validate to be protected
sthulb Jul 10, 2019
c149f0d
renames setBasicAuth to addBasicAuth
sthulb Jul 10, 2019
377504e
move func to comply with tslint rules
sthulb Jul 10, 2019
71d91a6
renames arn to branchArn
sthulb Jul 10, 2019
3d449ef
adds buildspec type
sthulb Jul 10, 2019
bf1d97b
adds buildspec
sthulb Jul 20, 2019
c1e845a
improves tests
sthulb Jul 20, 2019
e6d3c57
fix bug in isEmpty
sthulb Jul 21, 2019
8129713
adds tests for shared resolvers
sthulb Jul 21, 2019
de24948
fixes package.json
sthulb Jul 21, 2019
2dcd1ab
Adds extra tests
sthulb Jul 21, 2019
f2675b1
package-lock update
sthulb Jul 21, 2019
88487b7
create base interfaces
sthulb Jul 21, 2019
2c03876
add linking methods
sthulb Jul 21, 2019
d30f298
test new methods
sthulb Jul 21, 2019
5cfd540
test buildspec
sthulb Jul 21, 2019
876a3a3
Update @default values
sthulb Jul 21, 2019
bff9cfb
renames basicAuthConfig to basicAuth
sthulb Jul 24, 2019
9ebd209
adds extra doc strings
sthulb Jul 24, 2019
0884725
remove @example
sthulb Jul 24, 2019
a84e247
moves arn references to built in funcs
sthulb Jul 26, 2019
4abfb0b
update branchName
sthulb Jul 26, 2019
8c7ea38
Use codebuilld's buildspec
sthulb Jul 26, 2019
5f44d4d
changes role behaviour
sthulb Jul 26, 2019
13f7091
updates packages
sthulb Jul 26, 2019
80fe39f
removes old imports
sthulb Jul 26, 2019
4a9871a
removes resource prop
sthulb Jul 26, 2019
49fca18
changes buildspec from string
sthulb Jul 26, 2019
d583247
validates repository
sthulb Jul 26, 2019
4d8c685
adds @default
sthulb Jul 26, 2019
844ca59
add readme details
sthulb Jul 26, 2019
39c8a0a
fixes issue – certificate isn't a certificate
sthulb Jul 26, 2019
9b6adaa
adds a better example
sthulb Jul 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
132 changes: 130 additions & 2 deletions packages/@aws-cdk/aws-amplify/README.md
@@ -1,4 +1,11 @@
## AWS Amplify Construct Library

The AWS Amplify Console provides a Git-based workflow for deploying and hosting fullstack serverless web applications. A fullstack serverless app consists of a backend built with cloud resources such as GraphQL or REST APIs, file and data storage, and a frontend built with single page application frameworks such as React, Angular, Vue, or Gatsby.

Fullstack serverless web applications functionality is often spread across frontend code running in the browser and backend business logic running in the cloud. This makes application deployment complex and time consuming as you need to carefully coordinate release cycles to ensure your frontend and backend are compatible, and new features do not break your production customers.

The Amplify Console accelerates your application release cycle by providing a simple workflow for deploying full-stack serverless applications. You just connect your application's code repository to Amplify Console, and changes to your frontend and backend are deployed in a single workflow on every code commit.

<!--BEGIN STABILITY BANNER-->

---
Expand All @@ -15,8 +22,129 @@
---
<!--END STABILITY BANNER-->

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide some background about what is the Amplify service and what is this library capable of doing. As much as possible copy details and links from AWS documentation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Amplify service (known as the Amplify Console) offers continuous deployment and fully managed hosting for fullstack serverless web apps.

This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
## Create a Todo App
Using the sample application from VueJS (https://github.com/vuejs/vue/tree/dev/examples/todomvc), you can deploy a Todo app that uses VueJS.

The example will create an Amplify app that contains a BuildSpec and some custom rules to ensure files are able to be loaded correctly when the page is requested. It will also add domain pointing to the master branch.


```ts
const app = new amplify.App(stack, 'TodoApp', {
name: 'TodoApp',
repository: 'https://github.com/vuejs/vue',
description: 'TodoApp Example from VueJS',
oauthToken: new cdk.Secret('sometoken'),
buildSpec: codebuild.BuildSpec.fromObject({
version: 0.2,
frontend: {
phases: {
build: {
commands: [
'npm i'
'npm run build',
'cp dist/vue.min.js examples/todomvc/'
]
}
},
artifacts: {
baseDirectory: 'examples/todomvc/',
files: [
'*'
]
}
}
})
});

app.addCustomRule('/dist/vue.min.js', '/vue.min.js', '200');
app.addBranch('TodoMaster', {
branchName: 'master',
description: 'master branch'
});

app.addDomain('TodoDomain', {
domainName: 'example.com',
subdomainSettings: [{
branchName: 'master',
prefix: '/'
}]
})
```

## Add an App
Define a new App:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what an amplify app is. assume throughout this doc that people don't need to open 100 browser tabs to understand what they need to do. This should be as self-contained as possible.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An Amplify App is a collection of branches that represent frontend and backend environments.

```ts
new amplify.App(stack, 'MyApp', {
name: 'MyApp',
repository: 'https://github.com/aws/aws-cdk'
});
```
`App` constructs expose the following deploy-time attributes:
- `appId` - Unique Id for the Amplify App (i.e. `dbhvlzrug0n3u`)
- `appName` - Name for the Amplify App (i.e. `MyApp`)
- `appArn` - ARN for the Amplify App (i.e. `arn:aws:amplify:eu-west-1:1234567890123:apps/dbhvlzrug0n3u`)
- `appDefaultDomain` - Default domain for the Amplify App (i.e. `dbhvlzrug0n3u.amplifyapp.com`)

### Add Domain
```ts
const app = new amplify.App(stack, 'MyApp', {
name: 'MyApp',
repository: 'https://github.com/aws/aws-cdk'
});

app.addDomain('MyDomain', {
domainName: 'example.com',
subdomainSettings: [{
branchName: 'master',
prefix: '/'
}]
});
```

### Add Branch
```ts
const app = new amplify.App(stack, 'MyApp', {
name: 'MyApp',
repository: 'https://github.com/aws/aws-cdk'
});

app.addBranch('MyBranch', {
branchName: 'master'
});
```

## Domain
To add a domain to an existing app:
```ts
import amplify = require('@aws-cdk/aws-amplify');
const app = amplify.App.fromAppId(stack, 'MyApp', 'dbhvlzrug0n3u');

app.addDomain('MyDomain', {
domainName: 'example.com',
subdomainSettings: [{
branchName: 'master',
prefix: '/'
}]
})
```

The `Domain` construct exposes the following deploy-time attributes:
- `arn` - ARN for the Domain Association (i.e. `arn:aws:amplify:eu-west-1:12345678901234:apps/dbhvlzrug0n3u/domains/example.com`)
- `certificateRecord` - DNS Record for certificate verification (i.e. `_ed2e4e47958904855e7e12a2714c9d38.example.com. CNAME _d92413da499c5d5bd55611aeb2652633.duyqrilejt.acm-validations.aws.`)
- `domainName` - Name of the domain (i.e. `example.com`)
- `domainStatus` - Status fo the Domain Association (i.e. `AVAILABLE`)
- `statusReason` - Reason for the current status of the domain


## Branch
To add a branch to an existing app:
```ts
const app = amplify.App.fromAppId(stack, 'MyApp', 'dbhvlzrug0n3u');

app.addBranch('MyBranch', {
branchName: 'master'
})
```

`Branch` constructs expose the following deploy-time attributes:
- `branchArn` - ARN for a branch, part of an Amplify App. (i.e. `arn:aws:amplify:eu-west-1:12345678901234:apps/dbhvlzrug0n3u/branches/master`)
- `branchName` - Name for a branch, part of an Amplify App. (i.e. `master`)