Question: There are a bunch of windows ec2 instances running certain legacy applications that write application logs to the default path. Hence, we've attached a secondary volume (D: drive , 200GB for the application and it's logs). I'm now trying to create CW Alarms for diskspace using terraform but although the alarms created for each instance, are stuck in 'insufficient\_data' state forever.

The terraform snippet for CW alarm is as follows

```
data "aws_instances" "this" {
  filter {
    name   = "image-id"
    values = [data.aws_ami.this["windows"].image_id]
  }
}

resource "aws_cloudwatch_metric_alarm" "this" {
  for_each                  = toset(data.aws_instances.this.ids)
  alarm_name                = "Disk-space-${each.value}"
  comparison_operator       = "LessThanOrEqualToThreshold"
  evaluation_periods        = "1"
  metric_name               = "LogicalDisk % Free Space"
  namespace                 = "CWAgent"
  period                    = "180"
  statistic                 = "Average"
  threshold                 = "20"
  alarm_description         = "This metric monitors free space on application drive"
  actions_enabled           = "true"
  alarm_actions             = ["arn:aws:sns:xxxxxxx]
  insufficient_data_actions = []
  #treat_missing_data = "notBreaching"

  dimensions = {
    InstanceId = each.value
    Instance   = "D:"

  }
}

```

I'm guessing I've got the `dimensions` wrong. I also tried including `path = /` and `device= xvda` in `dimesions` but it still does not work. Any suggestions please?

Answer: 
State should be on top component and then passed down as props to the child components. States gets passed down and action gets passed up. By following this method you can pass file from child component to parent.
You can import images / their sources in a react component like this

```
import NameOfImage from '../../assets/file-name.jpg';

```

And then have that as a source or a prop to pass

```
<img src={NameOfImage}" />
//Or pass it to a component 
<Component image={NameOfImage} />

```

I've added a solution for changing state between components.

```
import { useEffect, useState } from "react";

const UploadImageForm = (props) => {
  const [image, setImage] = useState();

  const imageUpload = (e) => {
    const uploadedImagePath = e.target.files[0];
    setImage(URL.createObjectURL(uploadedImagePath));
  };
  const handleSubmit = (e) => {
    e.preventDefault();
    props.setUploadedImage(image);
  };

  return (
    <form onSubmit={handleSubmit}>
      <label>
        Name:
        <input type="file" onChange={(e) => imageUpload(e)} />
      </label>
      <input type="submit" value="Submit" />
    </form>
  );
};

const UploadedImage = (props) => {
  if (props.uploadedImage) {
    return <img src={props.uploadedImage} alt="Uploaded image" />;
  }
  return <h2>No image uploaded</h2>;
};

export default function App() {
  const [uploadedImage, setUploadedImage] = useState();

  return (
    <div className="App">
      <UploadImageForm
        uploadedImage={uploadedImage}
        setUploadedImage={setUploadedImage}
      />
      <UploadedImage uploadedImage={uploadedImage} />
    </div>
  );
}

```