Class: Putpaws::Provision::Resources::CodebuildProject
- Defined in:
- lib/putpaws/provision/resources/codebuild_project.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #changed?(current) ⇒ Boolean
- #create! ⇒ Object
- #current ⇒ Object
- #desired_params ⇒ Object
- #devops ⇒ Object
- #name ⇒ Object
- #outputs(current) ⇒ Object
- #security_group_ids ⇒ Object
- #update!(_current) ⇒ Object
Methods inherited from Base
#ensure!, #initialize, #kind, #plan
Constructor Details
This class inherits a constructor from Putpaws::Provision::Resources::Base
Instance Method Details
#changed?(current) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 58 def changed?(current) current.source&.type != desired_params[:source][:type] || current.source&.location != desired_params[:source][:location] || current.source&.buildspec != desired_params[:source][:buildspec] || current.service_role != desired_params[:service_role] || current.environment&.image != desired_params[:environment][:image] || current.environment&.compute_type != desired_params[:environment][:compute_type] || current.vpc_config&.subnets.to_a.sort != desired_params[:vpc_config][:subnets].sort || current.vpc_config&.security_group_ids.to_a.sort != desired_params[:vpc_config][:security_group_ids].sort end |
#create! ⇒ Object
69 70 71 72 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 69 def create! res = clients.codebuild.create_project(**desired_params) {codebuild_project: res.project.name} end |
#current ⇒ Object
53 54 55 56 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 53 def current res = clients.codebuild.batch_get_projects(names: [name]) res.projects.first end |
#desired_params ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 22 def desired_params { name: name, description: "Managed by putpaws for #{config.service_name}", source: { type: devops[:source_type] || 'GITHUB', location: devops[:source_repository], buildspec: devops[:buildspec] || 'buildspec.yml', }, artifacts: {type: 'NO_ARTIFACTS'}, environment: { type: 'LINUX_CONTAINER', image: devops[:environment_image] || 'aws/codebuild/standard:7.0', compute_type: devops[:compute_type] || 'BUILD_GENERAL1_SMALL', privileged_mode: devops.fetch(:privileged_mode, true), }, service_role: config.roles[:codebuild_role_arn], logs_config: { cloud_watch_logs: {status: 'ENABLED', group_name: config.build_log_group} }, # CI needs VPC access (Ex: db:migrate against RDS). Reuse the # service security group so the build reaches whatever the app can. vpc_config: { vpc_id: config.base[:vpc_id], subnets: config.base[:subnets], security_group_ids: security_group_ids, }, tags: [MANAGED_TAG], } end |
#devops ⇒ Object
12 13 14 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 12 def devops config.devops_settings end |
#name ⇒ Object
8 9 10 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 8 def name config.build_project_name end |
#outputs(current) ⇒ Object
79 80 81 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 79 def outputs(current) {codebuild_project: current.name} end |
#security_group_ids ⇒ Object
16 17 18 19 20 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 16 def security_group_ids ids = state.resources[:security_group_ids] raise "security_group_ids not found in state. Run the service step first." if ids.nil? || ids.empty? ids end |
#update!(_current) ⇒ Object
74 75 76 77 |
# File 'lib/putpaws/provision/resources/codebuild_project.rb', line 74 def update!(_current) res = clients.codebuild.update_project(**desired_params) {codebuild_project: res.project.name} end |