-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Have copy-to-s3 type support ZipBeforePut #107 * Use org-formation functions within a cloudformation template #108 * Detect unchanged register-type task and optimize to no-op #113 * New command: print all stacks for a task file #112
- Loading branch information
1 parent
ee37042
commit 213f858
Showing
67 changed files
with
986 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
examples/lambda-using-read-file/lambda-using-read-file.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
AWSTemplateFormatVersion: 2010-09-09-OC | ||
Description: Org formation example | ||
|
||
Resources: | ||
MyRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole | ||
AssumeRolePolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- lambda.amazonaws.com | ||
Action: | ||
- 'sts:AssumeRole' | ||
|
||
MyLambda: | ||
Type: AWS::Lambda::Function | ||
Properties: | ||
FunctionName: 'org-formation-example-lambda-using-read-file' | ||
Code: | ||
ZipFile: !ReadFile './src/index.js' | ||
Handler: index.handler | ||
Role: !GetAtt MyRole.Arn | ||
Runtime: nodejs12.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# this example uses features that are part of the 0.9.13 release | ||
|
||
OrganizationUpdate: | ||
Type: update-organization | ||
Skip: true | ||
Template: ./organization.yml | ||
|
||
DeployCodeAndLambda: | ||
Type: update-stacks | ||
Template: ./lambda-using-read-file.yml | ||
StackName: org-formation-example-lambda-using-read-file | ||
DefaultOrganizationBinding: | ||
Account: !Ref AccountA | ||
Region: eu-central-1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
AWSTemplateFormatVersion: '2010-09-09-OC' | ||
|
||
Organization: | ||
MasterAccount: | ||
Type: OC::ORG::MasterAccount | ||
Properties: | ||
AccountId: '102625093955' | ||
RootEmail: org-master@olafconijn.awsapps.com | ||
AccountName: Organization Master Account | ||
|
||
AccountA: | ||
Type: OC::ORG::Account | ||
Properties: | ||
RootEmail: account+a@olafconijn.awsapps.com | ||
AccountName: Account A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
exports.handler = function (event, context) { | ||
console.log(event); | ||
context.succeed('hello ' + event.name); | ||
}; |
40 changes: 40 additions & 0 deletions
40
examples/lambda-using-uploaded-zip/lambda-template-using-zip.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
AWSTemplateFormatVersion: 2010-09-09-OC | ||
Description: Org formation example | ||
|
||
Parameters: | ||
|
||
deploymentBucketName: | ||
Type: String | ||
Description: Name of the bucket that contains the lambda source code | ||
|
||
lambdaS3Key: | ||
Type: String | ||
Description: S3 Key that contains the location of lambda source code | ||
|
||
Resources: | ||
MyRole: | ||
Type: AWS::IAM::Role | ||
Properties: | ||
ManagedPolicyArns: | ||
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole | ||
AssumeRolePolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Effect: Allow | ||
Principal: | ||
Service: | ||
- lambda.amazonaws.com | ||
Action: | ||
- 'sts:AssumeRole' | ||
|
||
MyLambda: | ||
Type: AWS::Lambda::Function | ||
Properties: | ||
FunctionName: 'org-formation-example-lambda-using-uploaded-zip' | ||
Code: | ||
S3Bucket: !Ref deploymentBucketName | ||
S3Key: !Ref lambdaS3Key | ||
Handler: index.handler | ||
Role: !GetAtt MyRole.Arn | ||
Runtime: nodejs12.x |
49 changes: 49 additions & 0 deletions
49
examples/lambda-using-uploaded-zip/org-formation-deployment-bucket.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
AWSTemplateFormatVersion: 2010-09-09-OC | ||
|
||
Parameters: | ||
deploymentBucketName: | ||
Type: String | ||
|
||
organizationPrincipalId: | ||
Type: String | ||
|
||
Resources: | ||
|
||
OrgFormationDeploymentBucket: | ||
Type: AWS::S3::Bucket | ||
Properties: | ||
BucketName: !Ref deploymentBucketName | ||
BucketEncryption: | ||
ServerSideEncryptionConfiguration: | ||
- ServerSideEncryptionByDefault: | ||
SSEAlgorithm: AES256 | ||
|
||
|
||
OrgFormationDeploymentBucketPolicy: | ||
Type: AWS::S3::BucketPolicy | ||
Properties: | ||
Bucket: !Ref OrgFormationDeploymentBucket | ||
PolicyDocument: | ||
Version: '2012-10-17' | ||
Statement: | ||
- Sid: 'OwnerAllowEverything' | ||
Effect: 'Allow' | ||
Principal: | ||
AWS: !Ref AWS::AccountId | ||
Action: 's3:*' | ||
Resource: | ||
- !Sub '${OrgFormationDeploymentBucket.Arn}' | ||
- !Sub '${OrgFormationDeploymentBucket.Arn}/*' | ||
- Sid: 'OrgAllowGetObject' | ||
Effect: 'Allow' | ||
Principal: '*' | ||
Action: | ||
- 's3:GetObject' | ||
- 's3:GetObjectVersion' | ||
Resource: | ||
- !Sub '${OrgFormationDeploymentBucket.Arn}/*' | ||
Condition: | ||
StringEquals: | ||
'aws:PrincipalOrgID': | ||
- !Ref organizationPrincipalId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# this example uses features that are part of the 0.9.13 release | ||
|
||
|
||
Parameters: | ||
deploymentBucketName: | ||
Type: String | ||
Default: !Sub '${ORG::StateBucketName}-deployments' | ||
|
||
OrganizationUpdate: | ||
Type: update-organization | ||
Skip: true | ||
Template: ./organization.yml | ||
|
||
OrgFormationUploadBucket: | ||
Type: update-stacks | ||
Template: ./org-formation-deployment-bucket.yml | ||
StackName: org-formation-deployment-bucket | ||
StackDescription: Creates a bucket that can be used by org-formation to upload artifacts and use this bucket to deploy resources across the organization | ||
DefaultOrganizationBinding: | ||
IncludeMasterAccount: true | ||
Region: eu-central-1 | ||
Parameters: | ||
deploymentBucketName: !Ref deploymentBucketName | ||
organizationPrincipalId: !Ref ORG::PrincipalOrgID | ||
|
||
DeployLambdaSourceCode: | ||
Type: copy-to-s3 | ||
RemotePath: !Sub | ||
- s3://${bucket}/lambdas/my-lambda-source-${hashOfDir}.zip | ||
- { bucket: !Ref deploymentBucketName, hashOfDir: !MD5Dir ./src } | ||
LocalPath: ./src | ||
ZipBeforePut: true | ||
OrganizationBinding: | ||
IncludeMasterAccount: true | ||
Region: eu-central-1 | ||
|
||
DeployLambda: | ||
Type: update-stacks | ||
DependsOn: DeployLambdaSourceCode | ||
Template: ./lambda-template-using-zip.yml | ||
StackName: org-formation-example-lambda-using-uploaded-zip | ||
DefaultOrganizationBinding: | ||
Account: !Ref AccountA | ||
Region: eu-central-1 | ||
Parameters: | ||
deploymentBucketName: !Ref deploymentBucketName | ||
lambdaS3Key: !Sub | ||
- lambdas/my-lambda-source-${hashOfDir}.zip | ||
- { bucket: !Ref ORG::StateBucketName, hashOfDir: !MD5Dir ./src } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
AWSTemplateFormatVersion: '2010-09-09-OC' | ||
|
||
Organization: | ||
MasterAccount: | ||
Type: OC::ORG::MasterAccount | ||
Properties: | ||
AccountId: '102625093955' | ||
RootEmail: org-master@olafconijn.awsapps.com | ||
AccountName: Organization Master Account | ||
|
||
AccountA: | ||
Type: OC::ORG::Account | ||
Properties: | ||
RootEmail: account+a@olafconijn.awsapps.com | ||
AccountName: Account A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const logger = require('./logger') | ||
|
||
exports.handler = function (event, context) { | ||
logger.log(event); | ||
context.succeed('hello ' + event.name); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
exports.log = function (x) { | ||
console.log(x); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "org-formation-example-lambda", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "run-local.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const lambda = require('./index'); | ||
|
||
const event = {name: 'me'}; | ||
const context = { | ||
succeed: (x) => console.log(`succeeded: ${x}`) | ||
} | ||
lambda.handler(event, context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.