-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support to create well-known attributes for blocks #2504
Conversation
a6d6cb6
to
179a9c3
Compare
Note:
|
} | ||
) | ||
|
||
func randomShuffleValues(b *Block) cty.Value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me what we're doing here. From what I can tell we're essentially slicing the list - I assume that's so the result of this is always consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a function to mock the values returned from resource.random_shuffle
https://github.com/hashicorp/terraform-provider-random/blob/main/docs/resources/shuffle.md. This resource uses the result_count
attribute to return a slice of the input
attribute, which is randomly sorted. We don't randomly sort it here as it's unecessary for us, and a consistent output is probably better for debuging/tests. I'll add a comment to clarify.
regionalSvc := ec2.NewFromConfig(regionalConf) | ||
|
||
result, err := regionalSvc.DescribeAvailabilityZones(context.Background(), &ec2.DescribeAvailabilityZonesInput{ | ||
AllAvailabilityZones: aws.Bool(true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this returns the wavelength and other zones as well. I guess we only want these if the user has all_available_zones
on the data.aws_availability_zones
resource. I guess this is difficult because we have no way of knowing if the user has opted into them or not. So maybe if we find this is an issue with anyone in the future, we can always assume they've not opted into these zones as a default.
179a9c3
to
74d20b4
Compare
Goes some way to solving #1856 Adds support to return well-known values for blocks where mock data is insufficient. This is mostly applicable to data blocks. In particular data blocks such as `aws_availability_zones` where the return values can be inferred and don't require account/api access. This PR allows us to override the `Values` function for the `Block` with a more specific value func. Initial supported blocks are: * data.aws_availability_zones * data.google_compute_zones * resource.random_shuffle This pr also resolves an issue where the provider data was being set incorrectly in the evaluation context, using the key `provider` instead of `aws`, `google`, e.t.c.
74d20b4
to
6b7ec98
Compare
Goes some way to solving #1856
Adds support to return well-known values for blocks where mock data is insufficient. This is mostly applicable to data blocks. In particular data blocks such as
aws_availability_zones
where the return values can be inferred and don't require account/api access. This PR allows us to override theValues
function for theBlock
with a more specific value func.Initial supported blocks are:
This pr also resolves an issue where the provider data was being set incorrectly in the evaluation context, using the key
provider
instead ofaws
,google
, e.t.c.