User Tools

Site Tools


terraform:modules1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
terraform:modules1 [10/02/2025 17:17] andrewterraform:modules1 [12/02/2025 16:29] (current) andrew
Line 1: Line 1:
-====== Another Modules example ======+====== Basic Modules example ======
  
  
 To create an AWS parameter in a module, just the simplest example I could think of. The access key and secret are exported as shell variables. This is not the best way to do this, but the object of the excercise is to play with modules not authentication. To create an AWS parameter in a module, just the simplest example I could think of. The access key and secret are exported as shell variables. This is not the best way to do this, but the object of the excercise is to play with modules not authentication.
 +
 +===== Code =====
  
  
Line 48: Line 50:
 module "set_parameter" { module "set_parameter" {
   source     = "./set_parameter"   source     = "./set_parameter"
-  para_name "Myname" +  para_name var.test1 
-  para_value = "Myvalue"+  para_value = var.test2
 } }
  
Line 94: Line 96:
  
  
 +===== Result =====
 +
 +This outputs the arn of the parameter created.
 +
 +<code bash>
 +$ terraform apply
 +
 +Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
 +  + create
 +
 +Terraform will perform the following actions:
 +
 +  # module.set_parameter.aws_ssm_parameter.mypara will be created
 +  + resource "aws_ssm_parameter" "mypara" {
 +      + arn            = (known after apply)
 +      + data_type      = (known after apply)
 +      + id             = (known after apply)
 +      + insecure_value = (known after apply)
 +      + key_id         = (known after apply)
 +      + name           = "Myname"
 +      + tags_all       = {
 +          + "BuiltBy" = "Terraform"
 +        }
 +      + tier           = (known after apply)
 +      + type           = "String"
 +      + value          = (sensitive value)
 +      + version        = (known after apply)
 +    }
 +
 +Plan: 1 to add, 0 to change, 0 to destroy.
 +
 +Changes to Outputs:
 +  + Parameter_Name = (known after apply)
 +
 +
 +module.set_parameter.aws_ssm_parameter.mypara: Creating...
 +module.set_parameter.aws_ssm_parameter.mypara: Creation complete after 0s [id=Myname]
 +
 +Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
 +
 +Outputs:
 +
 +Parameter_Name = "arn:aws:ssm:eu-west-1:581230658448:parameter/variable1"
 +
 +$
 +</code>
  
 +''terraform destroy'' will remove the parameter.
  
  
  
  
terraform/modules1.1739207862.txt.gz · Last modified: by andrew

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki