Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Development Workflows on AWS

338 views

Published on

A walk-through of powering your end-to-end software development lifecycle using CodeCommit, CodePipeline, and CodeBuild.

  • Be the first to comment

  • Be the first to like this

Development Workflows on AWS

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Steve Engledow, AWS Professional Services 26 September, 2017 Development Workflows on AWS
  2. 2. Agenda 1. Service overview 2. Target application 3. Principles 4. Source control 5. Infrastructure 6. Application 7. Pipelines 8. Appendix 9. Q & A
  3. 3. Service Overview
  4. 4. CodeCommit • Managed source control • Highly scalable Git hosting • Integrates with: • other AWS services • third-party tools
  5. 5. CodePipeline • Continuous integration/delivery service • Multi-stage pipelines • Source • Test • Build • Deploy • Integrates with: • other AWS services • third-party tools
  6. 6. CodeBuild • Managed build service • Scales as needed • Concurrent builds • Integrates with: • other AWS services • third-party tools
  7. 7. Target Application
  8. 8. Target application $ cat hello-world-diagram.txt +--------+ +--------+ +---------+ | Python | | Deploy | → | Success | +--------+ +--------+ +---------+ ↓ ↑ ↓ +------+ +-------+ +--------+ | Test | → | Build | | Profit | +------+ +-------+ +--------+
  9. 9. Principles
  10. 10. Principles 1. Everything is code • Infrastructure • Application • Tests • Build process • Deployment process • Pipeline 2. All code must be version controlled 3. All code must be tested 4. All code tests, builds, and deployments must be automated
  11. 11. Source Control
  12. 12. Source control From the principles: 1. Everything is code 2. All code must be version controlled ∴ Everything must be version controlled CodeCommit API-driven: > aws codecommit create-repository --repository-name foobar > aws codecommit delete-repository --repository-name foobar > aws codecommit list-repositories etc.
  13. 13. Source control Example: $ aws codecommit create-repository --repository-name foobar { "repositoryMetadata": { "repositoryName": "foobar", "cloneUrlSsh": "ssh://git-codecommit.eu-west- 2.amazonaws.com/v1/repos/foobar", "lastModifiedDate": 1506411578.856, "repositoryId": "cad78efc-9291-47c3-9f61-b696087a2b2c", "cloneUrlHttp": "https://git-codecommit.eu-west- 2.amazonaws.com/v1/repos/foobar", "creationDate": 1506411578.856, "Arn": "arn:aws:codecommit:eu-west-2:654097458297:foobar", "accountId": "654097458297" } }
  14. 14. Source control jq (https://stedolan.github.io/jq/) is a great tool for parsing JSON. Getting a single value $ aws codecommit create-repository --repository-name foobar | jq -r .repositoryMetaData.cloneUrlSsh ssh://git-codecommit.eu-west-2.amazonaws.com/v1/repos/foobar Addressing a list $ aws codecommit list-repositories | jq -r .repositories[].repositoryName bazquux foobar hello-application hello-deck hello-pipeline xyzzy
  15. 15. Source control Setting up CodeCommit You need to associate your SSH key with your IAM user. This will give you a unique username; something like APKBIJVV4B627HXLUZVA Official instructions $ git remote add origin ssh://APKBIJVV4B627HXLUZVA@git-codecommit.eu-west- 2.amazonaws.com/v1/repos/foobar Advanced / Lazy (usually synonymous) Edit ~/.ssh/config: Host codecommit User APKBIJVV4B627HXLUZVA HostName git-codecommit.eu-west-2.amazonaws.com Then: $ git remote add origin ssh://codecommit/v1/repos/foobar
  16. 16. Infrastructure
  17. 17. Infrastructure as code We'll use a very simple CloudFormation template. CloudFormation is code. Description: Hello application Resources: Bucket: Type: AWS::S3::Bucket Properties: AccessControl: PublicRead BucketName: sengledo-hello-bucket WebsiteConfiguration: IndexDocument: index.html Outputs: URL: Description: Domain name of the Hello application Value: !GetAtt Bucket.WebsiteURL
  18. 18. Steps to deployment 1. Commit changes to CodeCommit • git push 2. CodePipeline test stage • Validate the CloudFormation template 3. CodePipeline build stage • Create a change set 4. CodePipeline deploy stage • Deploy the change set
  19. 19. The Application
  20. 20. The Application Just what the world needs: another static site generator! +-----------+ | timestamp | +-----------+ ↓ +---------------+ +--------------+ | template.html | → | generator.py | +---------------+ +--------------+ ↓ +------------+ | index.html | +------------+
  21. 21. Steps to deployment 1. Commit changes to CodeCommit • git push 2. CodePipeline test stage • Run the unit tests 3. CodePipeline build stage • Generate index.html 4. CodePipeline deploy stage • Upload index.html to the S3 bucket
  22. 22. Pipelines
  23. 23. Pipelines A tale of two pipelines: +------------------------+ +----------------------+ | CodeCommit: infra repo | | CodeCommit: app repo | +------------------------+ +----------------------+ ↓ ↓ +-----------------+ +-----------------+ | CodeBuild: test | | CodeBuild: test | +-----------------+ +-----------------+ ↓ ↓ +---------------------------+ +------------------+ | CloudFormation: ChangeSet | | CodeBuild: build | +---------------------------+ +------------------+ ↓ ↓ +-------------------------+ +-------------------+ | CloudFormation: Execute | | CodeBuild: deploy | +-------------------------+ +-------------------+
  24. 24. Pipelines Refer back to the principles 1. Everything is code 2. All code must be version controlled 3. All code must be tested 4. All code tests, builds, and deployments must be automated What does this mean? • The pipelines must be code too • CloudFormation • The pipelines need pipelines! • So meta • Those pipelines will be code too! • CloudFormation
  25. 25. The pipelines need pipelines! +---------------------------+ | CodeCommit: pipeline repo | +---------------------------+ ↓ +-----------------+ | CodeBuild: test | +-----------------+ ↓ +---------------------------+ | CloudFormation: ChangeSet | +---------------------------+ ↓ +-------------------------+ | CloudFormation: Execute | +-------------------------+
  26. 26. Appendix
  27. 27. Appendix • Don't forget you can do all of this with GitHub instead of CodeCommit • Suit your workflow to the application • Combined application and infrastructure or separate? • Manual approval steps? • Pull requests? • Not in CodeCommit (yet?) • Simple to emulate with another pipeline :) • One repository per user (as per GitHub) • CodePipeline responds to changes • Runs tests (can re-use existing CodeBuild projects) • Requests manual approval (code review?) • Merges (a trivial CodeBuild project)
  28. 28. Q & A
  29. 29. Q & A """ Q&A Function """ def main(host): audience = os.environ.get("AUDIENCE") with session as open(audience): for question in session: host.answer(question) if __name__ == "__main__": main("Steve")

×