diff --git a/doc/_resource_types/codebuild.md b/doc/_resource_types/codebuild.md index 3a2e7765..7d5558eb 100644 --- a/doc/_resource_types/codebuild.md +++ b/doc/_resource_types/codebuild.md @@ -1 +1,15 @@ ### exist + +```ruby +describe codebuild('my-codebuild1') do + it { should exist } +end +``` + +### have_tag + +```ruby +describe codebuild('my-codebuild1') do + it { should have_tag('env').value('dev') } +end +``` diff --git a/doc/resource_types.md b/doc/resource_types.md index 87231dbd..718ffcce 100644 --- a/doc/resource_types.md +++ b/doc/resource_types.md @@ -737,7 +737,22 @@ Codebuild resource type. ### exist +```ruby +describe codebuild('my-codebuild1') do + it { should exist } +end +``` + + +### have_tag + +```ruby +describe codebuild('my-codebuild1') do + it { should have_tag('env').value('dev') } +end +``` +### its(:name), its(:arn), its(:description), its(:secondary_sources), its(:source_version), its(:secondary_source_versions), its(:secondary_artifacts), its(:service_role), its(:timeout_in_minutes), its(:queued_timeout_in_minutes), its(:encryption_key), its(:created), its(:last_modified), its(:webhook), its(:vpc_config), its(:file_system_locations), its(:build_batch_config), its(:concurrent_build_limit), its(:project_visibility), its(:public_project_alias), its(:resource_access_role) ## codedeploy Codedeploy resource type. diff --git a/lib/awspec/generator/spec/iam_group.rb b/lib/awspec/generator/spec/iam_group.rb index 2ab5b641..0b60c930 100644 --- a/lib/awspec/generator/spec/iam_group.rb +++ b/lib/awspec/generator/spec/iam_group.rb @@ -27,7 +27,7 @@ def iam_group_spec_template describe iam_group('<%= group.group_name %>') do it { should exist } its(:arn) { should eq '<%= group.arn %>' } - its(:create_date) { should eq Time.parse('<%= group.create_date %>') } + its(:create_date) { should eq Time.parse('<%= group.create_date.utc %>') } <% select_iam_policy_by_group_name(group.group_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') } <% end %> <%- inline_policies.each do |line| -%> diff --git a/lib/awspec/generator/spec/iam_policy.rb b/lib/awspec/generator/spec/iam_policy.rb index 3d6a6942..410b4e1e 100644 --- a/lib/awspec/generator/spec/iam_policy.rb +++ b/lib/awspec/generator/spec/iam_policy.rb @@ -23,7 +23,7 @@ def policy_spec_template it { should_not be_attachable } <%- end -%> its(:arn) { should eq '<%= policy.arn %>' } - its(:update_date) { should eq Time.parse('<%= policy.update_date %>') } + its(:update_date) { should eq Time.parse('<%= policy.update_date.utc %>') } its(:attachment_count) { should eq <%= policy.attachment_count %> } <%- users = select_attached_users(policy.arn) -%> <%- if users.empty? -%> diff --git a/lib/awspec/generator/spec/iam_role.rb b/lib/awspec/generator/spec/iam_role.rb index 62899609..559fd05e 100644 --- a/lib/awspec/generator/spec/iam_role.rb +++ b/lib/awspec/generator/spec/iam_role.rb @@ -27,7 +27,7 @@ def iam_role_spec_template describe iam_role('<%= role.role_name %>') do it { should exist } its(:arn) { should eq '<%= role.arn %>' } - its(:create_date) { should eq Time.parse('<%= role.create_date %>') } + its(:create_date) { should eq Time.parse('<%= role.create_date.utc %>') } <% select_iam_policy_by_role_name(role.role_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') } <% end %> <%- inline_policies.each do |line| -%> diff --git a/lib/awspec/generator/spec/iam_user.rb b/lib/awspec/generator/spec/iam_user.rb index 4b4b4ce2..c5db9bf8 100644 --- a/lib/awspec/generator/spec/iam_user.rb +++ b/lib/awspec/generator/spec/iam_user.rb @@ -27,7 +27,7 @@ def iam_user_spec_template describe iam_user('<%= user.user_name %>') do it { should exist } its(:arn) { should eq '<%= user.arn %>' } - its(:create_date) { should eq Time.parse('<%= user.create_date %>') } + its(:create_date) { should eq Time.parse('<%= user.create_date.utc %>') } <% select_iam_policy_by_user_name(user.user_name).each do |policy| %> it { should have_iam_policy('<%= policy.policy_name %>') } <% end %> <%- inline_policies.each do |line| -%> diff --git a/lib/awspec/helper/finder/codebuild.rb b/lib/awspec/helper/finder/codebuild.rb index edafe45d..14c0e809 100644 --- a/lib/awspec/helper/finder/codebuild.rb +++ b/lib/awspec/helper/finder/codebuild.rb @@ -4,10 +4,8 @@ module Awspec::Helper module Finder module Codebuild def find_codebuild_project(id) - projects = select_all_codebuild_projects.select do |project| - project == id - end - projects.single_resource(id) + res = codebuild_client.batch_get_projects({ names: [id] }) + res.projects.single_resource(id) end def select_all_codebuild_projects diff --git a/lib/awspec/stub/codebuild.rb b/lib/awspec/stub/codebuild.rb index e2d868bc..56792a0e 100644 --- a/lib/awspec/stub/codebuild.rb +++ b/lib/awspec/stub/codebuild.rb @@ -2,6 +2,62 @@ Aws.config[:codebuild] = { stub_responses: { + batch_get_projects: { + projects: [ + { + name: 'my-codebuild1', + arn: 'arn:aws:codebuild:ap-northeast-1:123456789012:project/my-codebuild1', + source: { + type: 'S3', + location: 'example-bucket/test.zip', + insecure_ssl: false + }, + secondary_sources: [], + secondary_source_versions: [], + artifacts: { + type: 'NO_ARTIFACTS' + }, + secondary_artifacts: [], + cache: { + type: 'NO_CACHE' + }, + environment: { + type: 'LINUX_CONTAINER', + image: 'aws/codebuild/amazonlinux2-x86_64-standard:5.0', + compute_type: 'BUILD_GENERAL1_SMALL', + environment_variables: [], + privileged_mode: false, + image_pull_credentials_type: 'CODEBUILD' + }, + service_role: 'arn:aws:iam::123456789012:role/service-role/codebuild-my-codebuild1-service-role', + timeout_in_minutes: 60, + queued_timeout_in_minutes: 480, + encryption_key: 'arn:aws:kms:ap-northeast-1:123456789012:alias/aws/s3', + tags: [ + { + key: 'env', + value: 'dev' + } + ], + created: Time.local(2024), + last_modified: Time.local(2024), + badge: { + badge_enabled: false + }, + logs_config: { + cloud_watch_logs: { + status: 'ENABLED' + }, + s3_logs: { + status: 'DISABLED', + encryption_disabled: false + } + }, + project_visibility: 'PRIVATE' + } + ], + projects_not_found: [] + }, list_projects: { projects: %w[ my-codebuild1 diff --git a/lib/awspec/type/codebuild.rb b/lib/awspec/type/codebuild.rb index 944ad46e..5279efd5 100644 --- a/lib/awspec/type/codebuild.rb +++ b/lib/awspec/type/codebuild.rb @@ -2,6 +2,9 @@ module Awspec::Type class Codebuild < ResourceBase + aws_resource Aws::CodeBuild::Types::Project + tags_allowed + def resource_via_client @resource_via_client ||= find_codebuild_project(@display_name) end