Updating The Source Code
There are a few things that we will want to change before pushing this Blueprint up to AutoCloud and publishing it for folks to use. Firstly, let's go ahead and update the instructions for how to use the Blueprint since as they are currently, they don't make a whole lot of sense to expose to the end user. In your code editor, go down to line 495 and read them, they should look this.
As we can see this message is for you the cloud expert doing this tutorial, and is probably not the message we want to share with someone who wants to use the Blueprint to generate an S3 Bucket. Let's go ahead and delete the instructions that exist currently between lines 495-497 and replace them with the following:
Your code should now look like this:
While we're at it, let's update the author as well as the description of the blueprint, here is what they currently look like on lines 492 and 493:
Change the author to your email address, and update the description to be more terse so it says Create an AWS S3 Bucket
The author is the person who gets notified when the Blueprint is used, and that description is now easier for your users to understand. Let's go ahead and make a couple more changes. Currently, the name of the Bluerpint that will be displayed to users is "[Getting Started] KMS Encrypted S3 Bucket" as we can see on line 487.
Let's remove the "[Getting Started]" part, and just shorten the name to "AWS S3 Bucket" since our end users probably don't know or care about what KMS is. Your code should look like this:
Next, we're going to head up to the top of the file and look at the Namespace variable whose configuration starts on line 61.
This Namespace variable is the code responsible for rending the element of the form that we previously used.
Unless you work at AutoCloud, you probably don't want the value = "autocloud" on line 68 so let's go ahead and change the code on line 68 to be the name of your organization.
There is one last thing we're going to do before we push up this Blueprint to AutoCloud and test it. Currently, the form that we are presenting to end users has 6 different inputs but only three of these - Environment, Name, and Tags are editable. Namespace, Key Alias, and S3 Bucket Name are all read-only, with the latter two values being computed dynamically depending on the value of the Name input entered by the user. Here is what the form would look like if we were to use it right now:
Given that we're trying to make things simple for our users, let's make the form shorter and hide these read-only inputs referring to the specific AWS resources (questions #4 and #5 in the form above).
Start by hiding the Key Alias . Scroll up to line 146 and let's unpack a few concepts to help you understand what's happening:
Firstly, line 146 declares an autocloud_module resource called kms_key. If you were wondering how Blueprints reference the Terraform modules they build upon this is how. On line 137, we give the module we're using a name, which in this case is cpkmskey and on line 138, we have the module source which is just an open-source CloudPosse module from the public Terraform registry. Lastly, on line 139, we're selecting the version of the module we want, which in this case is 0.12.1.
We can also see the alias variable definition on line 171. Specifically, the name field on 172.
Head down to the bottom of the file where we put together the complete blueprint configuration and take a look at the omit_variablesdecleration on line 406:
This is the place where we can hide any variable we don't want the user to see, so let's add KMS Key section to line 457, and add the alias variable name like so:
If we were to now use the form, there would now only be 5 total inputs visible to the end user as Key Alias is now hidden. Don't worry, the Blueprint is still using this variable under the hood to do what it needs to do, but we've abstracted it away so the end user doesn't have to see it. Let's go ahead and repeat the process for S3 Bucket Name input.
Scroll up to line 242. Just as was the case with the KMS Key module, here we declare an autocloud_module resource called s3_bucket and set its configuration. Once again, we're using an open-source CloudPosse module:
Directly below on line 234, we're once again creating an "autocloud_blueprint_config" data object and calling it "s3_bucket" to match the above resource name.
Line 319 is where we're declaring the variable for the S3 Bucket Name and line 320 is where the name we need is being set. Copy the s3.variables.bucket_name and scroll down to line 446.
Paste s3.variables.bucket_name onto line 475 like so:
That's it, our Blueprint is now ready. Once you’ve made your changes, make sure to save the main.tf file so our changes take effect. Feel free to explore this file in more detail yourself, it’s very well documented and there is a world of possibility in terms of how Blueprints like this one can be configured. You can also view our Terraform provider documentation which explains all of the syntax in the main.tf file.
Let's now move on and push our Blueprint up to AutoCloud.