├── Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar ├── demo-site │ ├── README.md │ ├── appspec.yml │ ├── buildspec.yml │ ├── scripts │ │ ├── codestar_remote_access │ │ ├── install_dependencies │ │ ├── start_server │ │ └── stop_server │ ├── template-configuration.json │ ├── template.yml │ └── webpage │ │ └── index.html ├── myinput.json ├── mysrc.zip └── mytoolchain.yml ├── Pair-Programming-with-AWS-Cloud9 └── index.html └── Rolling-updates-to-a-highly-distributed-web-application-with-AWS-CodeDeploy ├── SampleApp_Linux.zip ├── SampleApp_Linux ├── LICENSE.txt ├── appspec.yml ├── index.html └── scripts │ ├── install_dependencies │ ├── start_server │ └── stop_server ├── SampleApp_Linux_update.zip └── SampleApp_Linux_update ├── LICENSE.txt ├── appspec.yml ├── index.html └── scripts ├── install_dependencies ├── start_server └── stop_server /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/README.md: -------------------------------------------------------------------------------- 1 | Welcome 2 | ======= 3 | 4 | This is a sample. -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/appspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.0 2 | os: linux 3 | files: 4 | - source: /webpage 5 | destination: /var/www 6 | hooks: 7 | AfterInstall: 8 | - location: scripts/install_dependencies 9 | timeout: 300 10 | runas: root 11 | - location: scripts/codestar_remote_access 12 | timeout: 300 13 | runas: root 14 | - location: scripts/start_server 15 | timeout: 300 16 | runas: root 17 | ApplicationStop: 18 | - location: scripts/stop_server 19 | timeout: 300 20 | runas: root 21 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.2 2 | 3 | phases: 4 | install: 5 | runtime-versions: 6 | java: openjdk8 7 | post_build: 8 | commands: 9 | 10 | # Do not remove this statement. This command is required for AWS CodeStar projects. 11 | # Update the AWS Partition, AWS Region, account ID and project ID in the project ARN in template-configuration.json file so AWS CloudFormation can tag project resources. 12 | - sed -i.bak 's/\$PARTITION\$/'${PARTITION}'/g;s/\$AWS_REGION\$/'${AWS_REGION}'/g;s/\$ACCOUNT_ID\$/'${ACCOUNT_ID}'/g;s/\$PROJECT_ID\$/'${PROJECT_ID}'/g' template-configuration.json 13 | 14 | artifacts: 15 | type: zip 16 | files: 17 | - '**/*' 18 | - 'template-configuration.json' 19 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/scripts/codestar_remote_access: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Install AWS CodeStar remote access management. 3 | # Allows project members to remotely access Amazon EC2 instances running Linux associated with the project. 4 | wget -O /usr/local/bin/get_authorized_keys https://awscodestar-templates-common.s3.amazonaws.com/us-east-1/get_authorized_keys 5 | chmod 755 /usr/local/bin/get_authorized_keys 6 | sed -i '/AuthorizedKeysCommand /s/.*/AuthorizedKeysCommand \/usr\/local\/bin\/get_authorized_keys/g' /etc/ssh/sshd_config 7 | sed -i '/AuthorizedKeysCommandUser /s/.*/AuthorizedKeysCommandUser root/g' /etc/ssh/sshd_config 8 | /etc/init.d/sshd restart 9 | yum update -y aws-cfn-bootstrap 10 | yum install -y aws-cli 11 | # Install pip and python dev libraries. 12 | yum install -y python27-devel python27-pip gcc 13 | pip install boto3 14 | pip install pycryptodome 15 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/scripts/install_dependencies: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | yum install -y nginx 3 | sed -i "s|/usr/share/nginx/html|/var/www|g" /etc/nginx/nginx.conf 4 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/scripts/start_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | service nginx start 3 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/scripts/stop_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | service nginx stop 3 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/template-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "Tags": 3 | { 4 | "awscodestar:projectArn":"arn:$PARTITION$:codestar:$AWS_REGION$:$ACCOUNT_ID$:project/$PROJECT_ID$" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/template.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | 3 | Conditions: 4 | IsBurstableInstanceType: !Equals [!Select [0, !Split ['.', !Ref InstanceType]], t2] 5 | 6 | Transform: 7 | - AWS::CodeStar 8 | 9 | Parameters: 10 | ProjectId: 11 | Type: String 12 | Description: AWS CodeStar project ID used to name project resources and create roles. 13 | InstanceType: 14 | Type: String 15 | Description: The type of Amazon EC2 Linux instances that will be launched for this project. 16 | ImageId: 17 | Type: String 18 | Description: The Amazon EC2 Linux instance Amazon Machine Image (AMI), which designates the configuration of the new instance. 19 | # KeyPairName: 20 | # Type: String 21 | # Description: The name of an existing Amazon EC2 key pair in the region where the project is created, which you can use to SSH into the new Amazon EC2 Linux instances. 22 | VpcId: 23 | Type: String 24 | Description: The ID of the Amazon Virtual Private Cloud (VPC) to use for Amazon EC2 instances. 25 | SubnetId: 26 | Type: String 27 | Description: The name of the VPC subnet to use for Amazon EC2 instances launched for this project. 28 | Stage: 29 | Type: String 30 | Description: The name for a project pipeline stage, such as Staging or Prod, for which resources are provisioned and deployed. 31 | 32 | Resources: 33 | WebApp01: 34 | Type: AWS::EC2::Instance 35 | Properties: 36 | CreditSpecification: 37 | CPUCredits: !If [IsBurstableInstanceType, unlimited, !Ref 'AWS::NoValue'] 38 | IamInstanceProfile: !Ref 'WebAppInstanceProfile' 39 | ImageId: !Ref 'ImageId' 40 | InstanceType: !Ref 'InstanceType' 41 | # KeyName: !Ref 'KeyPairName' 42 | NetworkInterfaces: 43 | - AssociatePublicIpAddress: true 44 | DeviceIndex: 0 45 | GroupSet: 46 | - !Ref 'WebAppSG' 47 | SubnetId: !Ref 'SubnetId' 48 | Tags: 49 | - Key: Environment 50 | Value: !Sub '${ProjectId}-WebApp${Stage}' 51 | - Key: Name 52 | Value: !Sub '${ProjectId}-WebApp${Stage}' 53 | UserData: 54 | Fn::Base64: 55 | Fn::Sub: | 56 | #!/bin/bash -ex 57 | # Install the AWS CodeDeploy Agent. 58 | cd /home/ec2-user/ 59 | wget https://aws-codedeploy-${AWS::Region}.s3.amazonaws.com/latest/codedeploy-agent.noarch.rpm 60 | yum -y install codedeploy-agent.noarch.rpm 61 | # Install the Amazon CloudWatch Logs Agent. 62 | wget https://s3.amazonaws.com/aws-cloudwatch/downloads/latest/awslogs-agent-setup.py 63 | wget https://s3.amazonaws.com/aws-codedeploy-us-east-1/cloudwatch/codedeploy_logs.conf 64 | wget https://s3.amazonaws.com/aws-codedeploy-us-east-1/cloudwatch/awslogs.conf 65 | chmod +x ./awslogs-agent-setup.py 66 | python awslogs-agent-setup.py -n -r ${AWS::Region} -c ./awslogs.conf 67 | mkdir -p /var/awslogs/etc/config 68 | cp codedeploy_logs.conf /var/awslogs/etc/config/ 69 | service awslogs restart 70 | 71 | WebAppSG: 72 | Type: AWS::EC2::SecurityGroup 73 | Properties: 74 | GroupDescription: Enable HTTP access via port 80 and SSH access via port 22. 75 | SecurityGroupIngress: 76 | - IpProtocol: tcp 77 | FromPort: '80' 78 | ToPort: '80' 79 | CidrIp: 0.0.0.0/0 80 | - IpProtocol: tcp 81 | FromPort: '22' 82 | ToPort: '22' 83 | CidrIp: 0.0.0.0/0 84 | VpcId: !Ref 'VpcId' 85 | 86 | WebAppInstanceProfile: 87 | Type: 'AWS::IAM::InstanceProfile' 88 | Properties: 89 | Path: / 90 | Roles: 91 | - !Ref WebAppRole 92 | 93 | WebAppRole: 94 | Type: 'AWS::IAM::Role' 95 | Properties: 96 | Path: / 97 | RoleName: !Sub 'CodeStarWorker-${ProjectId}-WebApp' 98 | AssumeRolePolicyDocument: 99 | Statement: 100 | - Action: 'sts:AssumeRole' 101 | Effect: Allow 102 | Principal: 103 | Service: ec2.amazonaws.com 104 | Sid: '' 105 | 106 | WebAppRolePolicies: 107 | Type: 'AWS::IAM::Policy' 108 | Properties: 109 | PolicyName: CodeStarWorkerBackendPolicy 110 | PolicyDocument: 111 | Statement: 112 | - Action: 113 | - 'ec2:Describe*' 114 | Resource: 115 | - '*' 116 | Effect: Allow 117 | - Action: 118 | - 's3:Get*' 119 | - 's3:List*' 120 | Resource: 121 | - '*' 122 | Effect: Allow 123 | - Action: 124 | - 'cloudformation:DescribeStackResources' 125 | Resource: 126 | - !Ref 'AWS::StackId' 127 | Effect: Allow 128 | - Action: 129 | - 'logs:CreateLogGroup' 130 | - 'logs:CreateLogStream' 131 | - 'logs:PutLogEvents' 132 | - 'logs:DescribeLogStreams' 133 | Resource: 134 | - !Sub 'arn:${AWS::Partition}:logs:*:*:*' 135 | Effect: Allow 136 | - Action: 137 | - 'codedeploy:BatchGet*' 138 | - 'codedeploy:Get*' 139 | - 'codedeploy:List*' 140 | Resource: 141 | - '*' 142 | Effect: Allow 143 | Roles: 144 | - !Ref WebAppRole -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/demo-site/webpage/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |But if it works, thats ok!
9 | 10 | -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/myinput.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Lab Demo", 3 | "id": "lab-demo", 4 | "description": "Project created with the CLI in a Linux Academy Lab", 5 | "sourceCode": [ 6 | { 7 | "source": { 8 | "s3": { 9 | "bucketName": "[BUCKET-NAME]", 10 | "bucketKey": "mysrc.zip" 11 | } 12 | }, 13 | "destination": { 14 | "codeCommit": { 15 | "name": "lab-demo" 16 | } 17 | } 18 | } 19 | ], 20 | "toolchain": { 21 | "source": { 22 | "s3": { 23 | "bucketName": "[BUCKET-NAME]", 24 | "bucketKey": "mytoolchain.yml" 25 | } 26 | }, 27 | "roleArn": "[AWS-CODESTAR-SERVICE-ROLE]", 28 | "stackParameters": { 29 | "ProjectId": "lab-demo", 30 | "VpcId": "[VPC-ID]", 31 | "SubnetId": "[SUBNET-ID]", 32 | "ImageId": "ami-00eb20669e0990cb4", 33 | "InstanceType": "t2.micro", 34 | "Stage": "Dev" 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/mysrc.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxacademy/content-aws-developertools/dfff009b9ad8a036b25a0ab4f869e8f26b6ce74d/Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/mysrc.zip -------------------------------------------------------------------------------- /Deploy-custom-code-with-a-CI_CD-pipline-using-AWS-CodeStar/mytoolchain.yml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | 3 | Description: Toolchain template for AWS CodeStar - Not for release into production accounts. 4 | 5 | Parameters: 6 | ProjectId: 7 | Type: String 8 | Description: AWS CodeStar project ID used to name project resources and create roles. 9 | InstanceType: 10 | Type: String 11 | Description: The type of Amazon EC2 Linux instances that will be launched for this project. 12 | ImageId: 13 | Type: String 14 | Description: The Amazon EC2 Linux instance Amazon Machine Image (AMI), which designates the configuration of the new instance. 15 | VpcId: 16 | Type: String 17 | Description: The ID of the Amazon Virtual Private Cloud (VPC) to use for Amazon EC2 instances. 18 | SubnetId: 19 | Type: String 20 | Description: The name of the VPC subnet to use for Amazon EC2 instances launched for this project. 21 | Stage: 22 | Type: String 23 | Description: The name for a project pipeline stage, such as Staging or Prod, for which resources are provisioned and deployed. 24 | 25 | Resources: 26 | CodeCommitRepo: 27 | Type: AWS::CodeCommit::Repository 28 | Properties: 29 | RepositoryDescription: !Sub "${ProjectId} repository" 30 | RepositoryName: !Ref ProjectId 31 | 32 | CodeBuildRole: 33 | Type: AWS::IAM::Role 34 | Properties: 35 | AssumeRolePolicyDocument: 36 | Statement: 37 | - Action: sts:AssumeRole 38 | Effect: Allow 39 | Principal: 40 | Service: codebuild.amazonaws.com 41 | Path: / 42 | RoleName: !Sub "CodeStarWorker-${ProjectId}-CodeBuild" 43 | 44 | CodeBuildPolicy: 45 | Type: AWS::IAM::Policy 46 | Properties: 47 | PolicyDocument: 48 | Statement: 49 | - Action: 50 | - logs:* 51 | - s3:* 52 | - kms:GenerateDataKey* 53 | - kms:Encrypt 54 | - kms:Decrypt 55 | Effect: Allow 56 | Resource: '*' 57 | PolicyName: CodeStarWorkerCodeBuildPolicy 58 | Roles: 59 | - !Ref 'CodeBuildRole' 60 | 61 | CodeBuildProject: 62 | Type: AWS::CodeBuild::Project 63 | DependsOn: 64 | - CodeBuildPolicy 65 | Properties: 66 | Artifacts: 67 | Packaging: zip 68 | Type: codepipeline 69 | Description: !Sub "AWS CodeStar created CodeBuild Project for ${ProjectId}" 70 | Environment: 71 | ComputeType: small 72 | EnvironmentVariables: 73 | - Name: S3_BUCKET 74 | Value: !Ref 'S3Bucket' 75 | - Value: !Ref ProjectId 76 | Name: PROJECT_ID 77 | - Value: !Ref 'AWS::AccountId' 78 | Name: ACCOUNT_ID 79 | - Value: !Ref 'AWS::Partition' 80 | Name: PARTITION 81 | Image: aws/codebuild/standard:2.0 82 | Type: LINUX_CONTAINER 83 | Name: !Ref 'ProjectId' 84 | ServiceRole: !Ref 'CodeBuildRole' 85 | Source: 86 | Type: codepipeline 87 | 88 | CloudFormationTrustRole: 89 | Type: AWS::IAM::Role 90 | Properties: 91 | AssumeRolePolicyDocument: 92 | Statement: 93 | - Action: sts:AssumeRole 94 | Effect: Allow 95 | Principal: 96 | Service: 97 | - cloudformation.amazonaws.com 98 | Path: / 99 | Policies: 100 | - PolicyDocument: 101 | Statement: 102 | - Action: 103 | - codecommit:* 104 | - codestar:* 105 | - codebuild:* 106 | - codedeploy:* 107 | - s3:* 108 | - ec2:* 109 | - cloudformation:* 110 | - iam:* 111 | Effect: Allow 112 | Resource: '*' 113 | PolicyName: CloudFormationRolePolicy 114 | RoleName: !Sub "CodeStarWorker-${ProjectId}-CFRole" 115 | 116 | S3ArtifactBucketPolicy: 117 | Type: AWS::S3::BucketPolicy 118 | Properties: 119 | Bucket: !Ref 'S3Bucket' 120 | PolicyDocument: 121 | Id: SSEAndSSLPolicy 122 | Statement: 123 | - Action: 124 | - s3:GetObject 125 | - s3:GetObjectVersion 126 | - s3:GetBucketVersioning 127 | Condition: 128 | Bool: 129 | aws:SecureTransport: false 130 | Effect: Allow 131 | Principal: 132 | AWS: 133 | - !GetAtt 'CodePipelineTrustRole.Arn' 134 | - !GetAtt 'CodeBuildRole.Arn' 135 | - !GetAtt 'CloudFormationTrustRole.Arn' 136 | Resource: 137 | - !Sub 'arn:aws:s3:::${S3Bucket}' 138 | - !Sub 'arn:aws:s3:::${S3Bucket}/*' 139 | Sid: WhitelistedGet 140 | - Action: 141 | - s3:PutObject 142 | Effect: Allow 143 | Principal: 144 | AWS: 145 | - !GetAtt 'CodePipelineTrustRole.Arn' 146 | - !GetAtt 'CodeBuildRole.Arn' 147 | Resource: 148 | - !Sub 'arn:aws:s3:::${S3Bucket}' 149 | - !Sub 'arn:aws:s3:::${S3Bucket}/*' 150 | Sid: WhitelistedPut 151 | Version: 2012-10-17 152 | 153 | S3Bucket: 154 | Type: AWS::S3::Bucket 155 | DeletionPolicy: Retain 156 | Properties: 157 | BucketName: !Sub "aws-codestar-${AWS::Region}-${AWS::AccountId}-${ProjectId}" 158 | Tags: 159 | - Key: Name 160 | Value: !Sub "${ProjectId}-S3Bucket" 161 | VersioningConfiguration: 162 | Status: Enabled 163 | 164 | CodePipelineTrustRole: 165 | Type: AWS::IAM::Role 166 | Properties: 167 | AssumeRolePolicyDocument: 168 | Statement: 169 | - Action: sts:AssumeRole 170 | Effect: Allow 171 | Principal: 172 | Service: 173 | - codepipeline.amazonaws.com 174 | Sid: 1 175 | Path: / 176 | Policies: 177 | - PolicyDocument: 178 | Statement: 179 | - Action: 180 | - codecommit:* 181 | - codestar:* 182 | - codebuild:* 183 | - codedeploy:* 184 | - s3:* 185 | - ec2:* 186 | - cloudformation:* 187 | - iam:* 188 | Effect: Allow 189 | Resource: '*' 190 | - Action: 191 | - iam:PassRole 192 | Effect: Allow 193 | Resource: 194 | - !GetAtt 'CloudFormationTrustRole.Arn' 195 | PolicyName: CodeStarWorkerCodePipelineRolePolicy 196 | RoleName: !Sub "CodeStarWorker-${ProjectId}-CodePipeline" 197 | 198 | ProjectPipeline: 199 | Type: AWS::CodePipeline::Pipeline 200 | DependsOn: 201 | - CodePipelineTrustRole 202 | - S3Bucket 203 | - CodeBuildProject 204 | - CloudFormationTrustRole 205 | Properties: 206 | ArtifactStore: 207 | Location: !Ref 'S3Bucket' 208 | Type: S3 209 | Name: !Sub "${ProjectId}-Pipeline" 210 | RoleArn: !GetAtt 'CodePipelineTrustRole.Arn' 211 | Stages: 212 | - Actions: 213 | - ActionTypeId: 214 | Category: Source 215 | Owner: AWS 216 | Provider: CodeCommit 217 | Version: 1 218 | Configuration: 219 | BranchName: master 220 | PollForSourceChanges: false 221 | RepositoryName: !Ref 'ProjectId' 222 | InputArtifacts: [] 223 | Name: ApplicationSource 224 | OutputArtifacts: 225 | - Name: !Sub "${ProjectId}-SourceArtifact" 226 | RunOrder: 1 227 | Name: Source 228 | - Actions: 229 | - ActionTypeId: 230 | Category: Build 231 | Owner: AWS 232 | Provider: CodeBuild 233 | Version: 1 234 | Configuration: 235 | ProjectName: !Ref 'ProjectId' 236 | InputArtifacts: 237 | - Name: !Sub "${ProjectId}-SourceArtifact" 238 | Name: PackageExport 239 | OutputArtifacts: 240 | - Name: !Sub "${ProjectId}-BuildArtifact" 241 | RunOrder: 1 242 | Name: Build 243 | - Actions: 244 | - ActionTypeId: 245 | Owner: AWS 246 | Category: Deploy 247 | Version: 1 248 | Provider: CloudFormation 249 | Configuration: 250 | TemplatePath: !Sub '${ProjectId}-BuildArtifact::template.yml' 251 | ActionMode: CHANGE_SET_REPLACE 252 | Capabilities: CAPABILITY_NAMED_IAM 253 | ParameterOverrides: !Sub | 254 | { 255 | "ProjectId":"${ProjectId}", 256 | "InstanceType":"${InstanceType}", 257 | "ImageId":"${ImageId}", 258 | "SubnetId":"${SubnetId}", 259 | "VpcId":"${VpcId}", 260 | "Stage":"${Stage}" 261 | } 262 | TemplateConfiguration: !Sub '${ProjectId}-BuildArtifact::template-configuration.json' 263 | ChangeSetName: pipeline-changeset 264 | RoleArn: !GetAtt 265 | - CloudFormationTrustRole 266 | - Arn 267 | StackName: !Sub 'awscodestar-${ProjectId}-infrastructure' 268 | InputArtifacts: 269 | - Name: !Sub '${ProjectId}-BuildArtifact' 270 | OutputArtifacts: [] 271 | RunOrder: 1 272 | Name: GenerateChangeSet 273 | - ActionTypeId: 274 | Owner: AWS 275 | Category: Deploy 276 | Version: 1 277 | Provider: CloudFormation 278 | Configuration: 279 | ActionMode: CHANGE_SET_EXECUTE 280 | ChangeSetName: pipeline-changeset 281 | StackName: !Sub 'awscodestar-${ProjectId}-infrastructure' 282 | InputArtifacts: [] 283 | OutputArtifacts: [] 284 | RunOrder: 2 285 | Name: ExecuteChangeSet 286 | - ActionTypeId: 287 | Owner: AWS 288 | Category: Deploy 289 | Version: 1 290 | Provider: CodeDeploy 291 | Configuration: 292 | ApplicationName: !Ref CodeDeployApplication 293 | DeploymentGroupName: !Ref DeploymentGroup 294 | InputArtifacts: 295 | - Name: !Sub '${ProjectId}-BuildArtifact' 296 | RunOrder: 3 297 | Name: Deploy 298 | Name: Deploy 299 | 300 | SourceEvent: 301 | Type: AWS::Events::Rule 302 | Properties: 303 | EventPattern: 304 | detail: 305 | event: 306 | - referenceCreated 307 | - referenceUpdated 308 | referenceName: 309 | - master 310 | referenceType: 311 | - branch 312 | detail-type: 313 | - CodeCommit Repository State Change 314 | resources: 315 | - !GetAtt 'CodeCommitRepo.Arn' 316 | source: 317 | - aws.codecommit 318 | Name: !Sub "awscodestar-${ProjectId}-SourceEvent" 319 | State: ENABLED 320 | Targets: 321 | - Arn: !Sub 'arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${ProjectId}-Pipeline' 322 | Id: ProjectPipelineTarget 323 | RoleArn: !GetAtt 'SourceEventRole.Arn' 324 | 325 | SourceEventRole: 326 | Type: AWS::IAM::Role 327 | Properties: 328 | AssumeRolePolicyDocument: 329 | Statement: 330 | - Action: sts:AssumeRole 331 | Effect: Allow 332 | Principal: 333 | Service: 334 | - events.amazonaws.com 335 | Sid: 1 336 | Policies: 337 | - PolicyDocument: 338 | Statement: 339 | - Action: 340 | - codepipeline:StartPipelineExecution 341 | Effect: Allow 342 | Resource: 343 | - !Sub "arn:aws:codepipeline:${AWS::Region}:${AWS::AccountId}:${ProjectId}-Pipeline" 344 | PolicyName: CodeStarWorkerCloudWatchEventPolicy 345 | RoleName: !Sub "CodeStarWorker-${ProjectId}-event-rule" 346 | 347 | CodeDeployApplication: 348 | Type: 'AWS::CodeDeploy::Application' 349 | Description: Configuring AWS CodeDeploy for project application 350 | Properties: 351 | ApplicationName: !Ref ProjectId 352 | 353 | DeploymentGroup: 354 | Type: 'AWS::CodeDeploy::DeploymentGroup' 355 | Description: Creating AWS CodeDeploy deployment groups for project application 356 | Properties: 357 | ApplicationName: !Ref CodeDeployApplication 358 | ServiceRoleArn: !GetAtt 359 | - ToolChainRole 360 | - Arn 361 | DeploymentConfigName: CodeDeployDefault.OneAtATime 362 | DeploymentGroupName: !Join 363 | - '' 364 | - - !Ref ProjectId 365 | - '-Env' 366 | Ec2TagFilters: 367 | - Type: KEY_AND_VALUE 368 | Value: !Join 369 | - '' 370 | - - !Ref ProjectId 371 | - '-WebApp' 372 | - !Ref Stage 373 | Key: Environment 374 | 375 | ToolChainRole: 376 | Type: 'AWS::IAM::Role' 377 | Properties: 378 | Path: / 379 | ManagedPolicyArns: 380 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSCodeCommitFullAccess' 381 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSCodeBuildAdminAccess' 382 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSCodeDeployFullAccess' 383 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSCodePipelineFullAccess' 384 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSElasticBeanstalkFullAccess' 385 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSLambdaFullAccess' 386 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/AWSCodeStarFullAccess' 387 | - !Sub 'arn:${AWS::Partition}:iam::aws:policy/CloudWatchEventsFullAccess' 388 | RoleName: !Sub 'CodeStarWorker-${ProjectId}-ToolChain' 389 | Policies: 390 | - PolicyName: ToolChainWorkerPolicy 391 | PolicyDocument: 392 | Statement: 393 | - Action: 394 | - 'kms:GenerateDataKey*' 395 | - 'kms:Encrypt' 396 | - 'kms:Decrypt' 397 | Resource: '*' 398 | Effect: Allow 399 | AssumeRolePolicyDocument: 400 | Statement: 401 | - Action: 'sts:AssumeRole' 402 | Effect: Allow 403 | Principal: 404 | Service: 405 | - codebuild.amazonaws.com 406 | - codedeploy.amazonaws.com 407 | - codepipeline.amazonaws.com 408 | - codestar.amazonaws.com 409 | - events.amazonaws.com 410 | -------------------------------------------------------------------------------- /Pair-Programming-with-AWS-Cloud9/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |6 | Learn Pair Programming with AWS Cloud9 7 |
8 | 9 | -------------------------------------------------------------------------------- /Rolling-updates-to-a-highly-distributed-web-application-with-AWS-CodeDeploy/SampleApp_Linux.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxacademy/content-aws-developertools/dfff009b9ad8a036b25a0ab4f869e8f26b6ce74d/Rolling-updates-to-a-highly-distributed-web-application-with-AWS-CodeDeploy/SampleApp_Linux.zip -------------------------------------------------------------------------------- /Rolling-updates-to-a-highly-distributed-web-application-with-AWS-CodeDeploy/SampleApp_Linux/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Rolling-updates-to-a-highly-distributed-web-application-with-AWS-CodeDeploy/SampleApp_Linux/appspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.0 2 | os: linux 3 | files: 4 | - source: /index.html 5 | destination: /var/www/html/ 6 | hooks: 7 | BeforeInstall: 8 | - location: scripts/install_dependencies 9 | timeout: 300 10 | runas: root 11 | - location: scripts/start_server 12 | timeout: 300 13 | runas: root 14 | ApplicationStop: 15 | - location: scripts/stop_server 16 | timeout: 300 17 | runas: root 18 | 19 | -------------------------------------------------------------------------------- /Rolling-updates-to-a-highly-distributed-web-application-with-AWS-CodeDeploy/SampleApp_Linux/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |For next steps, read the AWS CodeDeploy Documentation.
32 |