provider/aws: Remove unsafe ptr dereferencing from ECS/ECR (#8514)
This commit is contained in:
parent
ee4f96e07f
commit
2223964ff1
|
@ -60,8 +60,8 @@ func resourceAwsEcrRepositoryCreate(d *schema.ResourceData, meta interface{}) er
|
||||||
log.Printf("[DEBUG] ECR repository created: %q", *repository.RepositoryArn)
|
log.Printf("[DEBUG] ECR repository created: %q", *repository.RepositoryArn)
|
||||||
|
|
||||||
d.SetId(*repository.RepositoryName)
|
d.SetId(*repository.RepositoryName)
|
||||||
d.Set("arn", *repository.RepositoryArn)
|
d.Set("arn", repository.RepositoryArn)
|
||||||
d.Set("registry_id", *repository.RegistryId)
|
d.Set("registry_id", repository.RegistryId)
|
||||||
|
|
||||||
return resourceAwsEcrRepositoryRead(d, meta)
|
return resourceAwsEcrRepositoryRead(d, meta)
|
||||||
}
|
}
|
||||||
|
@ -86,8 +86,8 @@ func resourceAwsEcrRepositoryRead(d *schema.ResourceData, meta interface{}) erro
|
||||||
log.Printf("[DEBUG] Received repository %s", out)
|
log.Printf("[DEBUG] Received repository %s", out)
|
||||||
|
|
||||||
d.SetId(*repository.RepositoryName)
|
d.SetId(*repository.RepositoryName)
|
||||||
d.Set("arn", *repository.RepositoryArn)
|
d.Set("arn", repository.RepositoryArn)
|
||||||
d.Set("registry_id", *repository.RegistryId)
|
d.Set("registry_id", repository.RegistryId)
|
||||||
d.Set("name", repository.RepositoryName)
|
d.Set("name", repository.RepositoryName)
|
||||||
|
|
||||||
repositoryUrl := buildRepositoryUrl(repository, meta.(*AWSClient).region)
|
repositoryUrl := buildRepositoryUrl(repository, meta.(*AWSClient).region)
|
||||||
|
|
|
@ -53,7 +53,7 @@ func resourceAwsEcrRepositoryPolicyCreate(d *schema.ResourceData, meta interface
|
||||||
log.Printf("[DEBUG] ECR repository policy created: %s", *repositoryPolicy.RepositoryName)
|
log.Printf("[DEBUG] ECR repository policy created: %s", *repositoryPolicy.RepositoryName)
|
||||||
|
|
||||||
d.SetId(*repositoryPolicy.RepositoryName)
|
d.SetId(*repositoryPolicy.RepositoryName)
|
||||||
d.Set("registry_id", *repositoryPolicy.RegistryId)
|
d.Set("registry_id", repositoryPolicy.RegistryId)
|
||||||
|
|
||||||
return resourceAwsEcrRepositoryPolicyRead(d, meta)
|
return resourceAwsEcrRepositoryPolicyRead(d, meta)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ func resourceAwsEcrRepositoryPolicyRead(d *schema.ResourceData, meta interface{}
|
||||||
repositoryPolicy := out
|
repositoryPolicy := out
|
||||||
|
|
||||||
d.SetId(*repositoryPolicy.RepositoryName)
|
d.SetId(*repositoryPolicy.RepositoryName)
|
||||||
d.Set("registry_id", *repositoryPolicy.RegistryId)
|
d.Set("registry_id", repositoryPolicy.RegistryId)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ func resourceAwsEcrRepositoryPolicyUpdate(d *schema.ResourceData, meta interface
|
||||||
repositoryPolicy := *out
|
repositoryPolicy := *out
|
||||||
|
|
||||||
d.SetId(*repositoryPolicy.RepositoryName)
|
d.SetId(*repositoryPolicy.RepositoryName)
|
||||||
d.Set("registry_id", *repositoryPolicy.RegistryId)
|
d.Set("registry_id", repositoryPolicy.RegistryId)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func resourceAwsEcsClusterCreate(d *schema.ResourceData, meta interface{}) error
|
||||||
log.Printf("[DEBUG] ECS cluster %s created", *out.Cluster.ClusterArn)
|
log.Printf("[DEBUG] ECS cluster %s created", *out.Cluster.ClusterArn)
|
||||||
|
|
||||||
d.SetId(*out.Cluster.ClusterArn)
|
d.SetId(*out.Cluster.ClusterArn)
|
||||||
d.Set("name", *out.Cluster.ClusterName)
|
d.Set("name", out.Cluster.ClusterName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,21 +201,21 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
log.Printf("[DEBUG] Received ECS service %s", service)
|
log.Printf("[DEBUG] Received ECS service %s", service)
|
||||||
|
|
||||||
d.SetId(*service.ServiceArn)
|
d.SetId(*service.ServiceArn)
|
||||||
d.Set("name", *service.ServiceName)
|
d.Set("name", service.ServiceName)
|
||||||
|
|
||||||
// Save task definition in the same format
|
// Save task definition in the same format
|
||||||
if strings.HasPrefix(d.Get("task_definition").(string), "arn:aws:ecs:") {
|
if strings.HasPrefix(d.Get("task_definition").(string), "arn:aws:ecs:") {
|
||||||
d.Set("task_definition", *service.TaskDefinition)
|
d.Set("task_definition", service.TaskDefinition)
|
||||||
} else {
|
} else {
|
||||||
taskDefinition := buildFamilyAndRevisionFromARN(*service.TaskDefinition)
|
taskDefinition := buildFamilyAndRevisionFromARN(*service.TaskDefinition)
|
||||||
d.Set("task_definition", taskDefinition)
|
d.Set("task_definition", taskDefinition)
|
||||||
}
|
}
|
||||||
|
|
||||||
d.Set("desired_count", *service.DesiredCount)
|
d.Set("desired_count", service.DesiredCount)
|
||||||
|
|
||||||
// Save cluster in the same format
|
// Save cluster in the same format
|
||||||
if strings.HasPrefix(d.Get("cluster").(string), "arn:aws:ecs:") {
|
if strings.HasPrefix(d.Get("cluster").(string), "arn:aws:ecs:") {
|
||||||
d.Set("cluster", *service.ClusterArn)
|
d.Set("cluster", service.ClusterArn)
|
||||||
} else {
|
} else {
|
||||||
clusterARN := getNameFromARN(*service.ClusterArn)
|
clusterARN := getNameFromARN(*service.ClusterArn)
|
||||||
d.Set("cluster", clusterARN)
|
d.Set("cluster", clusterARN)
|
||||||
|
@ -224,7 +224,7 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
// Save IAM role in the same format
|
// Save IAM role in the same format
|
||||||
if service.RoleArn != nil {
|
if service.RoleArn != nil {
|
||||||
if strings.HasPrefix(d.Get("iam_role").(string), "arn:aws:iam:") {
|
if strings.HasPrefix(d.Get("iam_role").(string), "arn:aws:iam:") {
|
||||||
d.Set("iam_role", *service.RoleArn)
|
d.Set("iam_role", service.RoleArn)
|
||||||
} else {
|
} else {
|
||||||
roleARN := getNameFromARN(*service.RoleArn)
|
roleARN := getNameFromARN(*service.RoleArn)
|
||||||
d.Set("iam_role", roleARN)
|
d.Set("iam_role", roleARN)
|
||||||
|
@ -232,8 +232,8 @@ func resourceAwsEcsServiceRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if service.DeploymentConfiguration != nil {
|
if service.DeploymentConfiguration != nil {
|
||||||
d.Set("deployment_maximum_percent", *service.DeploymentConfiguration.MaximumPercent)
|
d.Set("deployment_maximum_percent", service.DeploymentConfiguration.MaximumPercent)
|
||||||
d.Set("deployment_minimum_healthy_percent", *service.DeploymentConfiguration.MinimumHealthyPercent)
|
d.Set("deployment_minimum_healthy_percent", service.DeploymentConfiguration.MinimumHealthyPercent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if service.LoadBalancers != nil {
|
if service.LoadBalancers != nil {
|
||||||
|
|
|
@ -140,7 +140,7 @@ func resourceAwsEcsTaskDefinitionCreate(d *schema.ResourceData, meta interface{}
|
||||||
*taskDefinition.TaskDefinitionArn, *taskDefinition.Revision)
|
*taskDefinition.TaskDefinitionArn, *taskDefinition.Revision)
|
||||||
|
|
||||||
d.SetId(*taskDefinition.Family)
|
d.SetId(*taskDefinition.Family)
|
||||||
d.Set("arn", *taskDefinition.TaskDefinitionArn)
|
d.Set("arn", taskDefinition.TaskDefinitionArn)
|
||||||
|
|
||||||
return resourceAwsEcsTaskDefinitionRead(d, meta)
|
return resourceAwsEcsTaskDefinitionRead(d, meta)
|
||||||
}
|
}
|
||||||
|
@ -160,9 +160,9 @@ func resourceAwsEcsTaskDefinitionRead(d *schema.ResourceData, meta interface{})
|
||||||
taskDefinition := out.TaskDefinition
|
taskDefinition := out.TaskDefinition
|
||||||
|
|
||||||
d.SetId(*taskDefinition.Family)
|
d.SetId(*taskDefinition.Family)
|
||||||
d.Set("arn", *taskDefinition.TaskDefinitionArn)
|
d.Set("arn", taskDefinition.TaskDefinitionArn)
|
||||||
d.Set("family", *taskDefinition.Family)
|
d.Set("family", taskDefinition.Family)
|
||||||
d.Set("revision", *taskDefinition.Revision)
|
d.Set("revision", taskDefinition.Revision)
|
||||||
d.Set("container_definitions", taskDefinition.ContainerDefinitions)
|
d.Set("container_definitions", taskDefinition.ContainerDefinitions)
|
||||||
d.Set("task_role_arn", taskDefinition.TaskRoleArn)
|
d.Set("task_role_arn", taskDefinition.TaskRoleArn)
|
||||||
d.Set("network_mode", taskDefinition.NetworkMode)
|
d.Set("network_mode", taskDefinition.NetworkMode)
|
||||||
|
|
Loading…
Reference in New Issue