Skip to content

Commit be76b28

Browse files
committedOct 30, 2018
Remove cluster_name completely while using describe_stacks
Signed-off-by: Balaji Sridharan <fnubalaj@amazon.com>
1 parent 9b8a2d2 commit be76b28

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed
 

‎README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ Changes
108108

109109
CfnCluster 1.6 IAM Change
110110
=========================
111-
Between CfnCluster 1.5.3 and 1.6.0 we made a change to the CfnClusterInstancePolicy that adds “s3:GetObject” permissions
111+
Between CfnCluster 1.5.4 and 1.6.0 we made a change to the CfnClusterInstancePolicy that adds “s3:GetObject” permissions
112112
on objects in <REGION>-cfncluster bucket, "autoscaling:SetDesiredCapacity", "autoscaling:DescribeTags" permissions and
113-
"cloudformation:DescribeStacks" permissions on <REGION>:<ACCOUNT_NAME>:<STACK_NAME>.
113+
"cloudformation:DescribeStacks" permissions on <REGION>:<ACCOUNT_ID>:stack/cfncluster-*.
114114
115115
If you’re using a custom policy (e.g. you specify "ec2_iam_role" in your config) be sure it includes this new permission. See https://cfncluster.readthedocs.io/en/latest/iam.html
116116

‎cli/cfncluster/cfnconfig.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __init__(self, args):
153153
print("ERROR: key_name set in [%s] section but not defined." % self.__cluster_section)
154154
sys.exit(1)
155155
if self.__sanity_check:
156-
config_sanity.check_resource(self.region, self.args.cluster_name, self.aws_access_key_id, self.aws_secret_access_key,
156+
config_sanity.check_resource(self.region, self.aws_access_key_id, self.aws_secret_access_key,
157157
'EC2KeyPair', self.key_name)
158158
except configparser.NoOptionError:
159159
print("ERROR: Missing key_name option in [%s] section." % self.__cluster_section)
@@ -173,7 +173,7 @@ def __init__(self, args):
173173
print("ERROR: template_url set in [%s] section but not defined." % self.__cluster_section)
174174
sys.exit(1)
175175
if self.__sanity_check:
176-
config_sanity.check_resource(self.region, self.args.cluster_name, self.aws_access_key_id, self.aws_secret_access_key,
176+
config_sanity.check_resource(self.region, self.aws_access_key_id, self.aws_secret_access_key,
177177
'URL', self.template_url)
178178
except configparser.NoOptionError:
179179
if self.region == 'us-gov-west-1':
@@ -208,7 +208,7 @@ def __init__(self, args):
208208
% (key, self.__vpc_section))
209209
sys.exit(1)
210210
if self.__sanity_check and self.__vpc_options.get(key)[1] is not None:
211-
config_sanity.check_resource(self.region, self.args.cluster_name, self.aws_access_key_id, self.aws_secret_access_key,
211+
config_sanity.check_resource(self.region, self.aws_access_key_id, self.aws_secret_access_key,
212212
self.__vpc_options.get(key)[1],__temp__)
213213
self.parameters.append((self.__vpc_options.get(key)[0],__temp__))
214214
except configparser.NoOptionError:
@@ -245,7 +245,7 @@ def __init__(self, args):
245245
% (key, self.__cluster_section))
246246
sys.exit(1)
247247
if self.__sanity_check and self.__cluster_options.get(key)[1] is not None:
248-
config_sanity.check_resource(self.region, self.args.cluster_name, self.aws_access_key_id, self.aws_secret_access_key,
248+
config_sanity.check_resource(self.region, self.aws_access_key_id, self.aws_secret_access_key,
249249
self.__cluster_options.get(key)[1],__temp__)
250250
self.parameters.append((self.__cluster_options.get(key)[0],__temp__))
251251
except configparser.NoOptionError:
@@ -294,7 +294,7 @@ def __init__(self, args):
294294
% (key, self.__ebs_section))
295295
sys.exit(1)
296296
if self.__sanity_check and self.__ebs_options.get(key)[1] is not None:
297-
config_sanity.check_resource(self.region, self.args.cluster_name, self.aws_access_key_id, self.aws_secret_access_key,
297+
config_sanity.check_resource(self.region, self.aws_access_key_id, self.aws_secret_access_key,
298298
self.__ebs_options.get(key)[1],__temp__)
299299
self.parameters.append((self.__ebs_options.get(key)[0],__temp__))
300300
except configparser.NoOptionError:
@@ -326,7 +326,7 @@ def __init__(self, args):
326326
% (key, self.__scaling_section))
327327
sys.exit(1)
328328
if self.__sanity_check and self.__scaling_options.get(key)[1] is not None:
329-
config_sanity.check_resource(self.region, self.args.cluster_name, self.aws_access_key_id, self.aws_secret_access_key,
329+
config_sanity.check_resource(self.region, self.aws_access_key_id, self.aws_secret_access_key,
330330
self.__scaling_options.get(key)[1],__temp__)
331331
self.parameters.append((self.__scaling_options.get(key)[0],__temp__))
332332
except configparser.NoOptionError:

‎cli/cfncluster/config_sanity.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_partition(region):
2626
return 'aws'
2727

2828

29-
def check_resource(region, cluster_name, aws_access_key_id, aws_secret_access_key, resource_type,resource_value):
29+
def check_resource(region, aws_access_key_id, aws_secret_access_key, resource_type, resource_value):
3030

3131
# Loop over all supported resource checks
3232
# EC2 KeyPair
@@ -57,13 +57,11 @@ def check_resource(region, cluster_name, aws_access_key_id, aws_secret_access_ke
5757
(['sqs:SendMessage', 'sqs:ReceiveMessage', 'sqs:ChangeMessageVisibility', 'sqs:DeleteMessage', 'sqs:GetQueueUrl'], "arn:%s:sqs:%s:%s:cfncluster-*" % (partition, region, accountid)),
5858
(['autoscaling:DescribeAutoScalingGroups', 'autoscaling:TerminateInstanceInAutoScalingGroup', 'autoscaling:SetDesiredCapacity', 'autoscaling:DescribeTags', 'autoScaling:UpdateAutoScalingGroup'], "*"),
5959
(['dynamodb:PutItem', 'dynamodb:Query', 'dynamodb:GetItem', 'dynamodb:DeleteItem', 'dynamodb:DescribeTable'], "arn:%s:dynamodb:%s:%s:table/cfncluster-*" % (partition, region, accountid)),
60+
(['cloudformation:DescribeStacks'], "arn:%s:cloudformation:%s:%s:stack/cfncluster-*" % (partition, region, accountid)),
6061
(['s3:GetObject'], "arn:%s:s3:::%s-cfncluster/*" % (partition, region)),
6162
(['sqs:ListQueues'], "*"),
6263
(['logs:*'], "arn:%s:logs:*:*:*" % partition)]
6364

64-
if cluster_name is not None:
65-
iam_policy['cloudformation:DescribeStacks'] = "arn:%s:cloudformation:%s:%s:stack/cfncluster-%s/*" % (partition, region, accountid, cluster_name)
66-
6765
for actions, resource_arn in iam_policy:
6866
response = iam.simulate_principal_policy(PolicySourceArn=arn, ActionNames=actions, ResourceArns=[resource_arn])
6967
for decision in response.get("EvaluationResults"):

‎cli/cfncluster/easyconfig.py

-3
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,5 @@ def configure(args):
177177
with open(config_file,'w') as cf:
178178
config.write(cf)
179179

180-
# Set cluster name to none, since it is needed by config sanity
181-
args.cluster_name = None
182-
183180
# Verify the configuration
184181
cfnconfig.CfnClusterConfig(args)

‎cloudformation/cfncluster.cfn.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -1947,11 +1947,7 @@
19471947
{
19481948
"Ref": "AWS::AccountId"
19491949
},
1950-
":stack/",
1951-
{
1952-
"Ref": "AWS::StackName"
1953-
},
1954-
"/*"
1950+
":stack/cfncluster-*"
19551951
]
19561952
]
19571953
}

‎docs/source/iam.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ IAM in CfnCluster
44
========================
55

66
.. warning::
7-
Between CfnCluster 1.5.4 and 1.6.0 we added a change to the `CfnClusterInstancePolicy` that adds “s3:GetObject” permissions on objects in <REGION>-cfncluster bucket and cloudformation:DescribeStacks" permissions on <REGION>:<ACCOUNT_ID>:stack/<STACK_NAME>
7+
Between CfnCluster 1.5.4 and 1.6.0 we added a change to the `CfnClusterInstancePolicy` that adds “s3:GetObject” permissions on objects in <REGION>-cfncluster bucket and cloudformation:DescribeStacks" permissions on <REGION>:<ACCOUNT_ID>:stack/cfncluster-*
88
If you're using a custom policy (e.g. you specify "ec2_iam_role" in your config) be sure it includes this new permission.
99

1010
Between CfnCluster 1.4.2 and 1.5.0 we added a change to the `CfnClusterInstancePolicy` that adds "ec2:DescribeVolumes" permissions. If you're using a custom policy (e.g. you specify "ec2_iam_role" in your config) be sure it includes this new permission.

0 commit comments

Comments
 (0)