-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource azurerm_static_site
#7150
Conversation
18f6f34
to
4818dc5
Compare
4818dc5
to
a9ea0be
Compare
a1ff335
to
71c1b1b
Compare
azurerm_static_site
azurerm_static_site
Implementation of the initial version is done, but to acctest this properly we would need the binary test functionality to generate the GitHub repo. |
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 @aristosvo
Thanks for this PR for this new Preview Resource.
It's looking pretty good, and I've left some comments in line below. The key point is that I think the resource can be simplified somewhat by flattening the schema and moving the github_configuration
contents to the top level.
We could also do with additional acceptance tests on the resource, in particular an update test, but any other additional appropriate coverage is welcome.
Just to set expectations appropriately...
There is something of a blocking issue on this resource for us. As you probably noticed, every create/destroy cycle leaves behind a GH Action in the branch used with a "pet" name for the deploy, and every one of them is executed every time a commit is made to that branch (or PR to it). In our testing environment this would result in many GH build/deploy actions firing (and failing, and sending emails) after relatively few testing cycles. (to see what I mean, take a look at the actions tab your repo from the tests). I'm going to try to reach out to the service team on this to find out the intent / future of this. Until that blocker is resolved in some way, we'll not be able to merge this.
nameSku := "Free" | ||
tierSku := "Free" |
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.
These should probably be an Optional
schema item, with a default of Free
. Whilst this service is in early preview only Free
is selectable in the portal, however, other the API information suggest that other values are possible (or going to be).
tierSku := "Free" | ||
staticSiteSkuDescription := &web.SkuDescription{Name: &nameSku, Tier: &tierSku} | ||
|
||
staticSiteType := "Microsoft.Web/staticSites" |
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.
You shouldn't need to set this, it is usually set by the service.
|
||
siteEnvelope := web.StaticSiteARMResource{ | ||
Sku: staticSiteSkuDescription, | ||
Type: &staticSiteType, |
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.
as noted above
Type: &staticSiteType, |
if err != nil { | ||
return fmt.Errorf("Error retrieving Static Site %q (Resource Group %q): %s", name, resGroup, err) | ||
} | ||
if read.ID == nil { |
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.
We should also check if the ID field is empty here
if read.ID == nil { | |
if read.ID == nil || read.ID == "" { |
"repo_token": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Sensitive: true, | ||
}, | ||
"repo_url": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"branch": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"app_location": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
"api_location": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
}, | ||
"artifact_location": { | ||
Type: schema.TypeString, | ||
Optional: 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.
Are there any sensible validation steps that can be taken for these items to catch problems at plan stage and prevent issues elsewhere?
"github_configuration": { | ||
Type: schema.TypeList, | ||
Required: true, | ||
Elem: &schema.Resource{ |
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.
I believe this resource could be made more simple by moving these items to the top level, rather than having a separate block.
(If there's a reason you feel it should be a block, I think this should have MaxItems: 1
)
) | ||
|
||
func skipStaticSite() bool { | ||
return os.Getenv("ARM_TEST_GITHUB_TOKEN") == "" |
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.
This should probably have a TF
prefix, rather than ARM
as these are for configuring the client itself, rather than test flags.
return os.Getenv("ARM_TEST_GITHUB_TOKEN") == "" | |
return os.Getenv("TF_ACCTEST_GITHUB_TOKEN") == "" |
Name string | ||
} | ||
|
||
func StaticSiteID(input string) (*StaticSiteResourceID, error) { |
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.
Could we have a test for this function as for other ID type elsewhere in the provider?
5b5e1ac
to
a3fba41
Compare
Hi @aristosvo |
would be really excited to see this come through, any updates please @jackofallops ? meanwhile could you or @aristosvo could you provide any quick documentation on how to include this as a patch for individuals who want to use it? maybe it doesnt make sense for the core/master right now but it doesn't mean other folks couldn't take advantage of it.. |
Without any meaningful updates in a while, I'm wondering if there is an alterative path forward - since
could the test be modified so that it includes test tear down behaviour to reach out to the defined GH repo/branch/token and remove the |
Hi @Oceanswave |
thanks @jackofallops . Any updates? Meanwhile, I managed to get this patched into my local version of Terraform and it works flawlessly. This was a big service to the community @aristosvo and is much appreciated! |
@payamazadi, could you please briefly outline how you've managed to patch this in locally? |
Is that possible to ask the service team provide an option to not create the workflow for users, rather return the content of the yaml file and the secret in the creation response. Then users can use the This way we do not need to involve the dependency on github related packages, and since we recently opt in the binary testing framework, it should also works for acctest. @jackofallops WDYT? |
@jackofallops and @aristosvo I've pushed two commits to this PR. One is to remove the repo-related properties from static site resource (to avoid service manipulate the repo) and adding some comptued properties (to allow users to add the api key and workflow to the repo by their own). I've passed the acctest locally: 💢 TF_ACC=1 go test -v -timeout=180m -run=TestAccAzureStaticSite_ ./...
2021/03/16 14:46:00 [DEBUG] not using binary driver name, it's no longer needed
2021/03/16 14:46:00 [DEBUG] not using binary driver name, it's no longer needed
=== RUN TestAccAzureStaticSite_basic
=== PAUSE TestAccAzureStaticSite_basic
=== RUN TestAccAzureStaticSite_requiresImport
=== PAUSE TestAccAzureStaticSite_requiresImport
=== CONT TestAccAzureStaticSite_basic
=== CONT TestAccAzureStaticSite_requiresImport
--- PASS: TestAccAzureStaticSite_basic (221.86s)
--- PASS: TestAccAzureStaticSite_requiresImport (240.79s) @jackofallops Please take another look, thank you! |
@magodo without the ability to connect this resource to a repository, the provisioned Static Site will be non-functional (e.g. no site will be deployed, which is the point of this service) - so this still appears to need service changes to be usable, or is there some other automated way of connecting the repo? |
@tombuildsstuff You can use the github terraform provider to do that, like this: https://gist.github.com/magodo/287009b96ebfa6b8c173e62d6907fa0f. |
Looks good within current limitations from my point of view! I'd probably add your example code to the documentation to have clear instructions how to use this resource, as without the GitHub configuration functionality is indeed limited. Just thinking out loud, but maybe we'd even go as far as adding that scenario as an acceptance test? 😇 Binary testing is awesome 🤩 |
@aristosvo Good point! The reason why I didn't add my example to the document is because currently there is a bug in the github provider, which will cause the provider panic on file creation. Anyway, I've added an example for this. |
Any update on this? The service has been announced as GA but we still haven’t got a way to provision using IaC.. |
@scuderig, asking the same question. Looking forward to use this via TF too. |
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.
Aside from one comment looks good to me 👍
This has been released in version 2.60.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.60.0"
}
# ... other configuration ... |
Co-authored-by: jackofallops <[email protected]> Co-authored-by: magodo <[email protected]> Co-authored-by: kt <[email protected]> Fixes hashicorp#7029
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #7029
TerraForm Spec
Acceptance Tests