Skip to content
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

Subnet nwacl changes #1941

Merged
merged 1 commit into from
Oct 8, 2020
Merged

Conversation

MalarvizhiK
Copy link
Member

Resource ibm subnet network acl attachment

},

isNetworkACLVPC: {
Type: schema.TypeString,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be only computed field

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.


isNetworkACLRules: {
Type: schema.TypeList,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also should be computed only

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.

},

isNetworkACLRuleTCP: {
Type: schema.TypeList,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.

},
},

isNetworkACLRuleUDP: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above comment

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.

},

isNetworkACLName: {
Type: schema.TypeString,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only computed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.


func resourceIBMISSubnetNetworkACLAttachmentUpdate(d *schema.ResourceData, meta interface{}) error {
hasChanged := false
if d.HasChange(isSubnetID) || d.HasChange(isNetworkACLID) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subnet_id cann't be updated it forces anew resource

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.


isNetworkACLName: {
Type: schema.TypeString,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be only computed field

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.


isNetworkACLResourceGroup: {
Type: schema.TypeString,
Optional: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be only computed field

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.


func resourceIBMISSubnetNetworkACLAttachmentUpdate(d *schema.ResourceData, meta interface{}) error {
hasChanged := false
if d.HasChange(isNetworkACLID) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of hasChanged variables since we have only one argument

d.HasChange(isNetworkACLID){
subnet := d.Get(isSubnetID).(string)
		networkACL := d.Get(isNetworkACLID).(string)

		// Construct an instance of the NetworkACLIdentityByID model
		networkACLIdentityModel := new(vpcv1.NetworkACLIdentityByID)
		networkACLIdentityModel.ID = &networkACL

		// Construct an instance of the ReplaceSubnetNetworkACLOptions model
		replaceSubnetNetworkACLOptionsModel := new(vpcv1.ReplaceSubnetNetworkACLOptions)
		replaceSubnetNetworkACLOptionsModel.ID = &subnet
		replaceSubnetNetworkACLOptionsModel.NetworkACLIdentity = networkACLIdentityModel
		resultACL, response, err := sess.ReplaceSubnetNetworkACL(replaceSubnetNetworkACLOptionsModel)

		if err != nil {
			log.Printf("[DEBUG] Error while attaching a network ACL to a subnet %s\n%s", err, response)
			return fmt.Errorf("Error while attaching a network ACL to a subnet %s\n%s", err, response)
		}
		log.Printf("[INFO] Updated subnet %s with Network ACL : %s", subnet, *resultACL.ID)
}
return resourceIBMISSubnetNetworkACLAttachmentRead(d, meta)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected this change.

@hkantare hkantare merged commit 8d81033 into IBM-Cloud:master Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants