本文整理汇总了Golang中k8s/io/kops/upup/pkg/fi/cloudup/terraform.TerraformTarget.AddFile方法的典型用法代码示例。如果您正苦于以下问题:Golang TerraformTarget.AddFile方法的具体用法?Golang TerraformTarget.AddFile怎么用?Golang TerraformTarget.AddFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kops/upup/pkg/fi/cloudup/terraform.TerraformTarget
的用法示例。
在下文中一共展示了TerraformTarget.AddFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RenderTerraform
func (_ *IAMRole) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *IAMRole) error {
policy, err := t.AddFile("aws_iam_role", *e.Name, "policy", e.RolePolicyDocument)
if err != nil {
return fmt.Errorf("error rendering RolePolicyDocument: %v", err)
}
tf := &terraformIAMRole{
Name: e.Name,
AssumeRolePolicy: policy,
}
return t.RenderResource("aws_iam_role", *e.Name, tf)
}
示例2: RenderTerraform
func (_ *SSHKey) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *SSHKey) error {
publicKey, err := t.AddFile("aws_key_pair", *e.Name, "public_key", e.PublicKey)
if err != nil {
return fmt.Errorf("error rendering PublicKey: %v", err)
}
tf := &terraformSSHKey{
Name: e.Name,
PublicKey: publicKey,
}
return t.RenderResource("aws_key_pair", *e.Name, tf)
}
示例3: RenderTerraform
func (_ *LaunchConfiguration) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *LaunchConfiguration) error {
cloud := t.Cloud.(*awsup.AWSCloud)
if e.ImageID == nil {
return fi.RequiredField("ImageID")
}
image, err := cloud.ResolveImage(*e.ImageID)
if err != nil {
return err
}
tf := &terraformLaunchConfiguration{
NamePrefix: fi.String(*e.Name + "-"),
ImageID: image.ImageId,
InstanceType: e.InstanceType,
}
if e.SSHKey != nil {
tf.KeyName = e.SSHKey.TerraformLink()
}
for _, sg := range e.SecurityGroups {
tf.SecurityGroups = append(tf.SecurityGroups, sg.TerraformLink())
}
tf.AssociatePublicIpAddress = e.AssociatePublicIP
if e.BlockDeviceMappings != nil {
tf.EphemeralBlockDevice = []*terraformBlockDevice{}
for deviceName, bdm := range e.BlockDeviceMappings {
tf.EphemeralBlockDevice = append(tf.EphemeralBlockDevice, &terraformBlockDevice{
VirtualName: bdm.VirtualName,
DeviceName: fi.String(deviceName),
})
}
}
if e.UserData != nil {
tf.UserData, err = t.AddFile("aws_launch_configuration", *e.Name, "user_data", e.UserData)
if err != nil {
return err
}
}
if e.IAMInstanceProfile != nil {
tf.IAMInstanceProfile = e.IAMInstanceProfile.TerraformLink()
}
// So that we can update configurations
tf.Lifecycle = &terraformLifecycle{CreateBeforeDestroy: fi.Bool(true)}
return t.RenderResource("aws_launch_configuration", *e.Name, tf)
}