Comments (19)
I'd like to revisit this conversation and add some learnings that we've gained from our side.
What we started doing was basically this (metacode):
ec2_client = Aws::EC2::Client.new()
res = ec2_client.describe_blah_resource(filters: [{filter thngie}])
my_resource__id = res['blah']['Id']
describe resource(my_resource_id) do....
There are a few problems at play here:
- We have dynamically created resources, so our names cannot be guaranteed.
- The code above won't work because of the converge model of a standard ruby based DSL. In other words, we can't create our stack, then check for the resources because the code outside of the DSL block ( describe in this case ) is executed before the methods of the DLS. In this case the EC2 client action would happen before the test, which breaks everything because the stack hasn't been created yet.
We have been addressing #2 by creating separate pipelines using different Jenkinsfiles in our projects to address the timing issue. So far it's worked well enough.
However, I would like to propose an idea here that would look like this:
search_thing = Awspec::Helper::SearchFilter.new({ 'Name' => 'NameTagOfThing' })
describe thing(search_thing) do....
The idea being that we have a class that can be passed into any finder that would extend the core search functionality.
I might even take this a step further and propose that we create a default SearchFilter for every finder, then allow the user to override the filter as needed.
This would solve both of our problems, and give awspec the ability to address dynamic resources in valuable way.
Thoughts?
from awspec.
Hi @krogebry !
I just released https://github.com/k1LoW/awsrm ! (although it is the minimum function)
If you want to test autoscalint_group by tag on awspec, you can use Awsrm::AutoscallingGroup.one
require 'spec_helper'
require 'awsrm'
describe autoscaling_group(Awsrm::AutoscallingGroup.one(tags: { Role: 'WebServer' }).id) do
it { should exist }
it { should have_tag('Role').value('WebServer') }
end
awsrm support only autoscaling_group
route_table
subnet
, now. I will increase support resources.
Regards.
from awspec.
Thanks for the response.
The thing is, we're using CFT's for our infrastructure management, which means we get an autogenerated name for the ASG. We can't guarantee consistency with the name of the ASG, and we also cannot specify the name in the CFT. We're thinking that we might have this problem with other resources down the road that we haven't gotten to yet.
I see that you throw an exception if more than one result is found for any given search, so it seems like you're already handling the condition of multiple resources existing. I would fully expect that if we had multiple resources with the same tag:Name value, that an exception would be thrown and the test would fail.
Can you help me understand what your apprehension is here? I'm interested in learning more about your approach.
from awspec.
I'm in the same situation where I'm using CFN to deploy Autoscaling Groups and other Resources where CloudFormation is assigning the names of those resources.
I'd generally like to be able to 'find' the Resource by using tags to locate it.
from awspec.
Addressed by #225 .
from awspec.
Hi @krogebry ! Thank you for your interesting idea.
I think
It is difficult for me to agree with "using Hash argument for tags ( key & value )".
Because,
Tags are usually assigned to multiple resources (so, you can not use awspec ).
And I do not want to handle only tags specially. ( Name
tag is special, because it is special on AMC )
Best Regards.
from awspec.
which means we get an autogenerated name for the ASG
mmm... it is true.
I have not use AWS CloudFormation Templates.
I do not want to handle only tags specially ( use Hash ), but I want to solve your problem.
from awspec.
I do not want to handle only tags specially ( use Hash ), but I want to solve your problem.
only tags? You can send the id of the object or a Hash structure. Or, did I misunderstand what you intended here?
I see you're in Japan, let me know if we have any communication problems with language or whatever. I'm more than happy to accommodate to your needs.
from awspec.
Sorry for my poor english;;
I do not want to handle only tags specially ( use Hash ), but I want to solve your problem.
- I do not want to use Hash args for tags "only"
- I understood your problem.
from awspec.
Do you have any ideas on how we might be able to get what we want here?
from awspec.
I have no idea now.
from awspec.
The way we've gone about this is to use Cloudformation stack outputs for each resource we want to spec test against. We prefix each output with "SPEC"
With a few helper ruby cloudformation stack utilities (cfndsl / bora) - it's pretty easy to share stack parameters and outputs without much code duplication between the stack template and spec.
from awspec.
@k1LoW Sorry to bug you, but I wanted to see about putting this on your radar again.
from awspec.
Your idea looks good to me ( search filter ).
I'm carefully considering this issue, now.
I will introduce my ideas at the moment.
Idea 1: find "only one" resource helper
describe ec2(ec2_filter(tags: {'Name' => 'NameTagOfThing'})) do
it { sholud be_running }
end
describe ec2(tags: {'Name' => 'NameTagOfThing'}) do # work ec2_filter() inside
it { sholud be_running }
end
same as @krogebry 's idea.
Idea 2: find multiple resource ids helper
ec2_instances(tags: {'Name' => 'NameTagOfThing'}).each |id|
describe ec2(id) do
it { sholud be_running }
end
end
ec2_instances(asg: 'my-asg').each |id|
describe ec2(id) do
it { sholud be_running }
end
end
Idea 3: Both 1 and 2
from awspec.
I agree with Idea 2.
from awspec.
Memo
https://aws.amazon.com/jp/blogs/aws/new-aws-resource-tagging-api/
from awspec.
@issuehuntfest has funded $20.00 to this issue. See it on IssueHunt
from awspec.
@k1LoW this one can be closed due the release of awsrm.
from awspec.
from awspec.
Related Issues (20)
- API Gateway tests fail if more than 25 APIs in Gateway even though APIs exist HOT 2
- Cannot do a negative test for security groups HOT 4
- The format of stub files HOT 1
- Support for using have_record_set for a cname record that point to multiple weighted targets HOT 1
- Apigateway resource, probable bug in https://github.com/k1LoW/awspec/blob/master/lib/awspec/type/apigateway.rb#L34 HOT 1
- Add support for S3 bucket location
- Networkissue when using Proxy HOT 2
- rds_parameter_group parameter check fails with 'method_missing' HOT 3
- route53_hosted_zone parameter check fails with 'no implicit conversion of Hash into String' HOT 1
- Documentation for eks_nodegroup is not working properly
- Filter tests (Run chosen tests only) HOT 1
- several warnings during testing
- Subnet finder missing by_cidr method HOT 1
- Missing details for iam_role and iam_policy
- cannot install due missing aws-sdk-core version
- Error requiring awspec when using Ruby 3.1.0 HOT 2
- Does awspec support RDS Aurora? HOT 2
- Error executing request, Exception : ComputeEnvironments and MaxResults cannot both be set
- aws_sfn_state_machine not exists HOT 1
- An error occurred while loading ./spec/ec2_spec.rb. - Did you mean? rspec ./spec/spec_helper.rbFailure/Error: require 'awspec'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awspec.