forked from awslabs/ssosync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Due to limitations of cross account execution, have need to split into two codepipeline instances, on in the production account and one in the staging account, building and testing respectively.
- Loading branch information
1 parent
23db2bd
commit e2b6810
Showing
27 changed files
with
2,116 additions
and
306 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: 0.2 | ||
|
||
phases: | ||
install: | ||
commands: | ||
# Update sam to latest version | ||
- wget -q https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip | ||
- unzip -q awscli-exe-linux-x86_64.zip | ||
- sudo ./aws/install --update | ||
- rm -rf ./aws awscli-exe-linux-x86_64.zip | ||
|
||
pre_build: | ||
commands: | ||
# Print all environment variables (handy for AWS CodeBuild logs) | ||
- env | ||
|
||
build: | ||
commands: | ||
- Parameters="[{\"ParameterKey\":\"AppArn\",\"ParameterValue\":\"${AppArn}\"}, {\"ParameterKey\":\"AppVersion\",\"ParameterValue\":\"${AppVersion}\"}]" | ||
- echo ${Parameters} | ||
|
||
- Capabilities="CAPABILITY_IAM CAPABILITY_AUTO_EXPAND" | ||
|
||
# Assume correct role on the staging account | ||
- export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" $(aws sts assume-role --role-arn "${ProductionAcctCodePipelineCloudFormationRole}" --role-session-name "CloudFormationRole" --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text)) | ||
|
||
# Create a changeset for the deployment | ||
- echo aws cloudformation create-change-set --stack-name "${StackName}" --template-body "file://${TemplatePath}" --parameters "${Parameters}" --capabilities ${Capabilities} --role-arn "${CloudFormationDeployerRole}" --change-set-name "${ChangeSetName}" --client-token "${ChangeSetName}" --change-set-type "CREATE" | ||
- aws cloudformation create-change-set --stack-name "${StackName}" --template-body "file://${TemplatePath}" --parameters "${Parameters}" --capabilities ${Capabilities} --role-arn "${CloudFormationDeployerRole}" --change-set-name "${ChangeSetName}" --client-token "${ChangeSetName}" --change-set-type "CREATE" | ||
|
||
# Wait for the change set to be created | ||
- aws cloudformation wait change-set-create-complete --stack-name "${StackName}" --change-set-name "${ChangeSetName}" | ||
|
||
# Deploy the changeset | ||
- aws cloudformation execute-change-set --stack-name "${StackName}" --change-set-name "${ChangeSetName}" | ||
|
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,14 @@ | ||
{ | ||
"Parameters": { | ||
"AppArn": "arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync-Staging", | ||
"AppVersion": "1.0.0-rc.10.23db2bd" | ||
}, | ||
"StackPolicy": { | ||
"Statement": [{ | ||
"Effect": "Allow", | ||
"NotAction": "Update:Delete", | ||
"Principal": "*", | ||
"Resource": "*" | ||
}] | ||
} | ||
} |
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,54 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: 'AWS::Serverless-2016-10-31' | ||
|
||
Description: | ||
This CloudFormation template will deploy an instance of the SSOSync-Staging | ||
candidate releases (via privately shared app in the AWS Serverless Application | ||
Repository (SAR) within the Staging Account. | ||
|
||
Parameters: | ||
AppArn: | ||
Description: The candidate release in the SAR | ||
Default: 'arn:aws:serverlessrepo:<AWS::Region>:<AccountId>:applications/<ApplicationName>' | ||
Type: String | ||
AppVersion: | ||
Description: The version of this build in SAR | ||
Default: 'v1.0.0-rc.10' | ||
Type: String | ||
|
||
Resources: | ||
SARApp: | ||
Type: AWS::Serverless::Application | ||
Properties: | ||
Location: | ||
ApplicationId: !Ref AppArn | ||
SemanticVersion: !Ref AppVersion | ||
Parameters: | ||
GoogleAdminEmail: '{{resolve:secretsmanager:TestGoogleAdminEmail}}' | ||
GoogleCredentials: '{{resolve:secretsmanager:TestGoogleCredentials}}' | ||
SCIMEndpointUrl: '{{resolve:secretsmanager:TestSCIMEndpointUrl}}' | ||
SCIMEndpointAccessToken: '{{resolve:secretsmanager:TestSCIMAccessToken}}' | ||
SyncMethod: groups | ||
GoogleUserMatch: 'name:*' | ||
GoogleGroupMatch: 'name:AWS*' | ||
LogLevel: warn | ||
LogFormat: json | ||
IgnoreUsers: None | ||
IgnoreGroups: None | ||
IncludeGroups: None | ||
ScheduleExpression: 'rate(1 day)' | ||
|
||
FunctionArnParam: | ||
Type: AWS::SSM::Parameter | ||
Properties: | ||
Name: "/SSOSync/Staging/FunctionArn" | ||
Type: String | ||
Value: !GetAtt SARApp.Outputs.FunctionArn | ||
Description: The Arn of the lambda function ssosync | ||
|
||
Outputs: | ||
FunctionArn: | ||
Description: "The Arn of the deployed lambda function" | ||
Value: !GetAtt SARApp.Outputs.FunctionArn | ||
Export: | ||
Name: FunctionArn |
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,22 @@ | ||
version: 0.2 | ||
|
||
env: | ||
secrets-manager: | ||
GoogleAdminEmail: TestGoogleAdminEmail | ||
SCIMEndpointUrl: TestSCIMEndpointUrl | ||
SCIMAccessToken: TestSCIMAccessToken | ||
|
||
phases: | ||
pre_build: | ||
commands: | ||
# Print all environment variables (handy for AWS CodeBuild logs) | ||
- env | ||
|
||
build: | ||
commands: | ||
- ls -la | ||
- ./ssosync --version | ||
- aws secretsmanager get-secret-value --secret-id=TestGoogleCredentials --query SecretString --output text | jq '.' > credentials.json | ||
- cat credentials.json | ||
|
||
- ./ssosync -t "${SCIMAccessToken}" -e "${SCIMEndpointUrl}" -u "${GoogleAdminEmail}" -s "groups" -g "name:AWS*" |
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,16 @@ | ||
version: 0.2 | ||
|
||
phases: | ||
pre_build: | ||
commands: | ||
# Print all environment variables (handy for AWS CodeBuild logs) | ||
- env | ||
|
||
build: | ||
commands: | ||
# Create a changeset for the deployment | ||
- aws lambda invoke --function-name "SSOSyncFunction" response.json | ||
|
||
artifacts: | ||
files: | ||
- response.json |
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.