List of usage examples for com.amazonaws.services.ec2 AmazonEC2 authorizeSecurityGroupIngress
AuthorizeSecurityGroupIngressResult authorizeSecurityGroupIngress( AuthorizeSecurityGroupIngressRequest authorizeSecurityGroupIngressRequest);
Adds the specified ingress rules to a security group.
From source file:jp.classmethod.aws.gradle.ec2.AmazonEC2AuthorizeSecurityGroupIngressTask.java
License:Apache License
@TaskAction public void authorizeIngress() { // to enable conventionMappings feature String groupId = getGroupId(); Object ipPermissions = getIpPermissions(); if (groupId == null) { throw new GradleException("groupId is not specified"); }/*from w ww . jav a 2 s .c om*/ if (ipPermissions == null) { throw new GradleException("ipPermissions is not specified"); } AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class); AmazonEC2 ec2 = ext.getClient(); try { ec2.authorizeSecurityGroupIngress(new AuthorizeSecurityGroupIngressRequest().withGroupId(groupId) .withIpPermissions(parse(ipPermissions))); } catch (AmazonServiceException e) { if (e.getErrorCode().equals("InvalidPermission.Duplicate")) { getLogger().warn(e.getMessage()); } else { throw e; } } }
From source file:org.xmlsh.aws.gradle.ec2.AmazonEC2AuthorizeSecurityGroupIngressTask.java
License:BSD License
@TaskAction public void authorizeIngress() { // to enable conventionMappings feature String groupId = getGroupId(); Object ipPermissions = getIpPermissions(); if (groupId == null) throw new GradleException("groupId is not specified"); if (ipPermissions == null) throw new GradleException("ipPermissions is not specified"); AmazonEC2PluginExtension ext = getProject().getExtensions().getByType(AmazonEC2PluginExtension.class); AmazonEC2 ec2 = ext.getClient(); try {/*ww w . j a v a 2 s. c o m*/ ec2.authorizeSecurityGroupIngress(new AuthorizeSecurityGroupIngressRequest().withGroupId(groupId) .withIpPermissions(parse(ipPermissions))); } catch (AmazonServiceException e) { if (e.getErrorCode().equals("InvalidPermission.Duplicate")) { getLogger().warn(e.getMessage()); } else { throw e; } } }