aws-samples / automated-iot-fleet-provisioning-by-claim

MIT No Attribution
19 stars 10 forks source link

Failing cloud formation #3

Open anandlalvb-rvs opened 3 years ago

anandlalvb-rvs commented 3 years ago

I am getting this error every time when I ran the SAM cloud formation template

Embedded stack arn:aws:cloudformation:us-west-2:<account_id>:stack/iotfleetprov-IoT-<id>/70920bb0-5ef5-11eb-8668-06d3cec249cb was not successfully created: The following resource(s) failed to create: [CertMonitorFunctionCheckCertExpiryEvent, FleetProvisioningHookPermission, FleetProvisioningCustom, CertRotationHookPermission].

CLI command:

aws cloudformation create-stack --region us-west-2 --stack-name iot-prov-pipeline --template-body file://pipeline.yaml --capabilities CAPABILITY_NAMED_IAM --parameters ParameterKey=CodeRepositoryName,ParameterValue=automated-iot-fleet-provisioning-by-claim ParameterKey=CodeRepositoryBranch,ParameterValue=master ParameterKey=ResourceTag,ParameterValue=iotfleetprov --profile IoT Note: Running the cloud formation using Admin keys

Please fix this and help me to understand the error

Update: the template worked fine in N Virginia region

anandlalvb-rvs commented 3 years ago

The possible reason is the code assumed the regions as default (us-east-1)

From s3 CLI doc

If you send your create bucket request to the s3.amazonaws.com endpoint, the request goes to the us-east-1 Region.

For boto3, we have to use

        location = {'LocationConstraint': region}
        s3Client.create_bucket(Bucket=model_bucket, CreateBucketConfiguration=location)

Instead of

s3Client.create_bucket(Bucket=model_bucket)