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
Feature/add api gateway stage data source #8890
Feature/add api gateway stage data source #8890
Conversation
One issue I ran into that I did not expect was when using data "aws_api_gateway_stage" "example" {
depends_on = ["aws_api_gateway_stage.example"]
rest_api_id = "${aws_api_gateway_rest_api.test.id}"
stage_name = "prod"
}
|
1a07282
to
6ee79d8
Compare
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.
Hi @FreekingDean 👋 Thanks so much for your contribution here. I left some initial feedback items below -- please reach out if you have any questions or do not have time to implement them.
Regarding your earlier comment about depends_on
: the usage of depends_on
with data sources can be problematic with perpetual read updates and its usage is discouraged in general for data sources. We do have some documentation about this here, if you are interested in reading more: https://www.terraform.io/docs/configuration/data-sources.html#data-resource-dependencies
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"current_deployment_id": { |
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.
Since the API refers to this as deployment ID, should we remove current_
from the naming?
} | ||
|
||
d.SetId(fmt.Sprintf("ags-%s-%s", restApiID, stageName)) | ||
d.Set("current_deployment_id", *stage.DeploymentId) |
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.
Dereferencing the string pointer via *
can introduce potential panics without a nil
check and is extraneous here as d.Set()
automatically will handle nil
👍
d.Set("current_deployment_id", *stage.DeploymentId) | |
d.Set("deployment_id", stage.DeploymentId) |
|
||
data "aws_api_gateway_stage" "example" { | ||
rest_api_id = "${aws_api_gateway_rest_api.test.id}" | ||
stage_name = "${basename(aws_api_gateway_stage.example.invoke_url)}" |
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.
Can we use stage_name = "${aws_api_gateway_stage.example.stage_name}"
instead?
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.
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccDataSourceAwsApiGatewayStage -timeout 120m
? github.com/terraform-providers/terraform-provider-aws [no test files]
=== RUN TestAccDataSourceAwsApiGatewayStage
=== PAUSE TestAccDataSourceAwsApiGatewayStage
=== CONT TestAccDataSourceAwsApiGatewayStage
--- PASS: TestAccDataSourceAwsApiGatewayStage (27.37s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 27.411s
Just to note that Acceptance tests still pass :)
I believe I resolved all outstanding comments @bflad! Let me know if theres anything else you see that sticks out! |
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.
Small little things then should be good to go!
stage_name = "production" | ||
} | ||
|
||
resource "aws_api_gateway_stage" "production" { |
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.
Should this be named prod
to match the stage_name
below or vice versa? Maybe blue/green? Admittedly this example feels a little confusing to me for a use case since it doesn't show overwriting any stage settings. 😅
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.
Hopefully this is a bit better, our use case was:
We had a system that updated & deployed an api gateway stage, but wanted to configure settings (specifically the logging settings via terraform). This would cause issues every time we applied since a deployment is required as an attribute, this change will allow us to just use the latest deployment as input to the stage resource so we dont revery the api gateway on each trerraform apply!
Co-Authored-By: Brian Flad <bflad417@gmail.com>
Co-Authored-By: Brian Flad <bflad417@gmail.com>
3bd3b01
to
6a4a6b2
Compare
Hopefully they are addressed! |
Anything needed for this? |
Just wanted to see if there were changes requested! :D |
Hey! Just wanted to do a last checkin to see if theres something I can do to help this through :) |
Just want to bump this again to see what I can do to help! |
Any updates to this? |
Is there anything blocking this? This is something that is impacting us! |
Fixed the merge conflict! |
Closing this to clean up my open PRs |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Release note for CHANGELOG:
Output from acceptance testing: